From ramana.kumar at gmail.com Sat Jan 8 17:52:55 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 8 Jan 2011 17:52:55 +0000 Subject: [opentheory-users] opentheory development Message-ID: Is the opentheory tool under version control, and if so is it possible to get checkin access? I don't have anything to add, yet, so maybe this message is premature :P It looks like you may have implemented everything in SML already anyway, but I think the package management tool for ArchLinux (pacman) is generic, so could be used for dealing with repositories and dependencies and such. I don't have experience using it except for with archlinux packages, though. From ramana.kumar at gmail.com Sat Jan 8 17:54:44 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 8 Jan 2011 17:54:44 +0000 Subject: [opentheory-users] article reader for HOL4 Message-ID: Does anyone know if there's an article reader for HOL4? Or, in fact, which theorem provers have article readers, and where can they be found? I'm thinking if there is none for HOL4 I should write it, and then put it with the HOL4 sources - or should it come with the opentheory? From ramana.kumar at gmail.com Sat Jan 8 17:58:30 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 8 Jan 2011 17:58:30 +0000 Subject: [opentheory-users] article repository Message-ID: Is there a repository of opentheory articles anywhere? The only ones I've seen so far are in the test directory of the opentheory package. Have you seen the hol-online project? http://code.google.com/p/hol-online/ I'm not sure how theories are going to be stored there, but maybe we should try to mirror it at least in opentheory. From ramana.kumar at gmail.com Sat Jan 8 18:04:43 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 8 Jan 2011 18:04:43 +0000 Subject: [opentheory-users] article repository In-Reply-To: References: Message-ID: It seems that opentheory knows about a "gilith" repository as soon as you install it. Is there a way to list all the packages in a repository, or search a repository? Also, what about getting info on it, like is this gilith repository on the web or is it somewhere local on my hard disk? On Sat, Jan 8, 2011 at 5:58 PM, Ramana Kumar wrote: > Is there a repository of opentheory articles anywhere? > The only ones I've seen so far are in the test directory of the > opentheory package. > Have you seen the hol-online project? http://code.google.com/p/hol-online/ > I'm not sure how theories are going to be stored there, but maybe we > should try to mirror it at least in opentheory. > From ramana.kumar at gmail.com Sun Jan 9 13:19:11 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sun, 9 Jan 2011 13:19:11 +0000 Subject: [opentheory-users] parsing article information Message-ID: opentheory info --summary pkg gives me some useful information, in particular the list of theorems the package ought to produce. I want to use this to test my HOL4 article reader, so I can compare the theorems I generate against what the article is supposed to generate. (info --summary could be helpful in automatically determining required thms/types/constants too) Q1: Is this information available by a more appropriate means than calling info --summary? Q2: The article file for bool-def-1.0, say, seems to talk about constants with the prefix "Data.Bool.", but in info --summary this prefix is stripped off. How should I find out that there may be a prefix like this to deal with? (I saw some "show" thing in the output from opentheory once - is that documented? what does it mean?) Q2.1: How should I deal with the prefix? Should the article reader strip it off names in the article file, so that the generated theorems end up looking more like info --summary, or should I create theorems with the prefix and add the prefix when parsing the summary? Q3: Are there any published rules or grammar for how info --summary terms (and theorems) are printed? Q4: info --summary doesn't give the arity of the required type operators or the types of the required constants... I think these can be figured out by actually reading the article, but by then it might be too late for someone making a call to read_article who wants to provide the requirements. can+should opentheory print this information (maybe optionally)? From ramana.kumar at gmail.com Sun Jan 9 13:43:22 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sun, 9 Jan 2011 13:43:22 +0000 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: I have added a preliminary version of an article reader to HOL4 (hol.sf.net, svn r8839) Which other proof assistants have readers, by the way? Is there a list somewhere? On Sat, Jan 8, 2011 at 5:54 PM, Ramana Kumar wrote: > Does anyone know if there's an article reader for HOL4? > Or, in fact, which theorem provers have article readers, and where can > they be found? > I'm thinking if there is none for HOL4 I should write it, and then put > it with the HOL4 sources - or should it come with the opentheory? > From joe at gilith.com Sun Jan 9 18:44:17 2011 From: joe at gilith.com (Joe Hurd) Date: Sun, 9 Jan 2011 10:44:17 -0800 Subject: [opentheory-users] opentheory development In-Reply-To: References: Message-ID: Hi Ramana, The opentheory tool is under git version control: instructions for getting a development snapshot are available at http://src.gilith.com/opentheory.html Rather than manage accounts for check-in access, I'm going to try the "Integration-Manager Workflow" described at http://progit.org/book/ch5-1.html Cheers, Joe On Sat, Jan 8, 2011 at 9:52 AM, Ramana Kumar wrote: > Is the opentheory tool under version control, and if so is it possible > to get checkin access? > I don't have anything to add, yet, so maybe this message is premature :P > > It looks like you may have implemented everything in SML already > anyway, but I think the package management tool for ArchLinux (pacman) > is generic, so could be used for dealing with repositories and > dependencies and such. I don't have experience using it except for > with archlinux packages, though. > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Sun Jan 9 18:49:26 2011 From: joe at gilith.com (Joe Hurd) Date: Sun, 9 Jan 2011 10:49:26 -0800 Subject: [opentheory-users] article repository In-Reply-To: References: Message-ID: Hi Ramana, The web repositories are still being actively worked on, and haven't been officially "released" yet, but browse through the gilith repo http://opentheory.gilith.com/ to see which packages are installed on it. The packages live on this web repo, and package repo lists are stored locally in your ~/.opentheory/repos directory. Cheers, Joe On Sat, Jan 8, 2011 at 10:04 AM, Ramana Kumar wrote: > It seems that opentheory knows about a "gilith" repository as soon as > you install it. > Is there a way to list all the packages in a repository, or search a repository? > Also, what about getting info on it, like is this gilith repository on > the web or is it somewhere local on my hard disk? > > On Sat, Jan 8, 2011 at 5:58 PM, Ramana Kumar wrote: >> Is there a repository of opentheory articles anywhere? >> The only ones I've seen so far are in the test directory of the >> opentheory package. >> Have you seen the hol-online project? http://code.google.com/p/hol-online/ >> I'm not sure how theories are going to be stored there, but maybe we >> should try to mirror it at least in opentheory. >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Sun Jan 9 19:03:40 2011 From: joe at gilith.com (Joe Hurd) Date: Sun, 9 Jan 2011 11:03:40 -0800 Subject: [opentheory-users] parsing article information In-Reply-To: References: Message-ID: Hi Ramana, > Q1: Is this information available by a more appropriate means than > calling info --summary? opentheory info --summary is supposed to generate article summaries in a human readable form: as of now there is no machine-readable version of it other than the article file. > Q2: The article file for bool-def-1.0, say, seems to talk about > constants with the prefix "Data.Bool.", but in info --summary this > prefix is stripped off. How should I find out that there may be a > prefix like this to deal with? (I saw some "show" thing in the output > from opentheory once - is that documented? what does it mean?) You are correct: the (as yet documented) show tags in a theory determines how the namespaces get transformed as names are printed. To see a pure version remove all show tags or just run opentheory info --summary directly on the article file. > Q2.1: How should I deal with the prefix? Should the article reader > strip it off names in the article file, so that the generated theorems > end up looking more like info --summary, or should I create theorems > with the prefix and add the prefix when parsing the summary? I would recommend creating a mapping from fully-qualified OpenTheory names to their HOL4 versions. The file opentheory/test/interpretations/hol-light.int is an example showing how HOL Light names map to the OpenTheory namespace. > Q3: Are there any published rules or grammar for how info --summary > terms (and theorems) are printed? There's no documentation on this (other than the source code), but I'll reiterate that it's supposed to be a human-readable form of the summary, justifying tricks such as printing HOL numerals as decimal numerals. > Q4: info --summary doesn't give the arity of the required type > operators or the types of the required constants... I think these can > be figured out by actually reading the article, but by then it might > be too late for someone making a call to read_article who wants to > provide the requirements. can+should opentheory print this information > (maybe optionally)? This is an interesting point: right now the type of an input constant is not contained anywhere in the article (just types of uses of the constant). For now I'm going to hope that this information is known to the reader. Cheers, Joe From joe at gilith.com Sun Jan 9 19:08:06 2011 From: joe at gilith.com (Joe Hurd) Date: Sun, 9 Jan 2011 11:08:06 -0800 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: Hi Ramana, Thanks for implementing this: HOL4 is now the first theorem prover with an article reader! I'd like to try it out: how do I run it? Cheers, Joe On Sun, Jan 9, 2011 at 5:43 AM, Ramana Kumar wrote: > I have added a preliminary version of an article reader to HOL4 > (hol.sf.net, svn r8839) > > Which other proof assistants have readers, by the way? Is there a list > somewhere? > > On Sat, Jan 8, 2011 at 5:54 PM, Ramana Kumar wrote: >> Does anyone know if there's an article reader for HOL4? >> Or, in fact, which theorem provers have article readers, and where can >> they be found? >> I'm thinking if there is none for HOL4 I should write it, and then put >> it with the HOL4 sources - or should it come with the opentheory? >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Sun Jan 9 21:00:34 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sun, 9 Jan 2011 21:00:34 +0000 Subject: [opentheory-users] parsing article information In-Reply-To: References: Message-ID: On Sun, Jan 9, 2011 at 7:03 PM, Joe Hurd wrote: > Hi Ramana, > >> Q1: Is this information available by a more appropriate means than >> calling info --summary? > > opentheory info --summary is supposed to generate article summaries in > a human readable form: as of now there is no machine-readable version > of it other than the article file. Will there be? I can probably get opentheory to spit one out by catching it just before it prints the human-readable version and sending whatever data structures it is using to a different printer. > >> Q2: The article file for bool-def-1.0, say, seems to talk about >> constants with the prefix "Data.Bool.", but in info --summary this >> prefix is stripped off. How should I find out that there may be a >> prefix like this to deal with? (I saw some "show" thing in the output >> from opentheory once - is that documented? what does it mean?) > > You are correct: the (as yet documented) show tags in a theory > determines how the namespaces get transformed as names are printed. To > see a pure version remove all show tags or just run opentheory info > --summary directly on the article file. If I generate the article file with opentheory, though, the namespace information is there. How do I get a pure article file for say bool-1.0? > >> Q2.1: How should I deal with the prefix? Should the article reader >> strip it off names in the article file, so that the generated theorems >> end up looking more like info --summary, or should I create theorems >> with the prefix and add the prefix when parsing the summary? > > I would recommend creating a mapping from fully-qualified OpenTheory > names to their HOL4 versions. The file > > opentheory/test/interpretations/hol-light.int > > is an example showing how HOL Light names map to the OpenTheory namespace. I don't quite understand how this is all going to fit together... HOL4 already has a boolTheory with a proof script. Now the gilith repo has one too, represented by the package (and ultimately the article), which was presumably generated from a different (e.g. HOL-light) script. If I try to match the constants up within HOL4, that means I should be in a context where those constants are already defined, but when I run the article it's going to try to redefine them. In other words it seems like either I build the article's theory, or I build the existing theory, and I don't need, and can't have, both, so what sense is there in getting their names to match? (Well I can have both, but they won't interact, in which case I wouldn't want the names to match...) This is perhaps worth discussing in a separate email thread... feel free to change the subject line. > >> Q3: Are there any published rules or grammar for how info --summary >> terms (and theorems) are printed? > > There's no documentation on this (other than the source code), but > I'll reiterate that it's supposed to be a human-readable form of the > summary, justifying tricks such as printing HOL numerals as decimal > numerals. > >> Q4: info --summary doesn't give the arity of the required type >> operators or the types of the required constants... I think these can >> be figured out by actually reading the article, but by then it might >> be too late for someone making a call to read_article who wants to >> provide the requirements. can+should opentheory print this information >> (maybe optionally)? > > This is an interesting point: right now the type of an input constant > is not contained anywhere in the article (just types of uses of the > constant). For now I'm going to hope that this information is known to > the reader. > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Sun Jan 9 21:12:34 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sun, 9 Jan 2011 21:12:34 +0000 Subject: [opentheory-users] order of arguments to eqMp Message-ID: Is the documentation of the file format here http://www.gilith.com/research/opentheory/article.html#eqMpCommand correct? My reader appears to be saying that the article file corresponding to bool-1.0 wants |- phi to be popped before |- phi' = psi From ramana.kumar at gmail.com Sun Jan 9 20:43:42 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sun, 9 Jan 2011 20:43:42 +0000 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: On Sun, Jan 9, 2011 at 7:08 PM, Joe Hurd wrote: > Hi Ramana, > > Thanks for implementing this: HOL4 is now the first theorem prover > with an article reader! > > I'd like to try it out: how do I run it? At this stage it's going to break on anything interesting you try it on... But the basic method would be: Build the latest svn version of HOL4 In a HOL4 session, do: val input = (* article file, e.g. TextIO.openIn("/path/to/file.art") *) val asms = (* net of theorems the article depends on, you can use Opentheory.thmsFromList ls to create this from a list of HOL4 theorems *) val consts = (* dictionary of constants the article depends on, keyed by their name, and represented by functions (hol_type -> term). You can use Opentheory.constsFromList ls, e.g. constsFromList [("=",fn ty => Term.mk_const("=",ty))] *) val types = (* dictionary of types the article depends on, keyed by their names, and represented by functions (hol_type list -> hol-type). You can use Opentheory.typesFromList ls, e.g. typesFromList [("->",fn ls => Type.mk_type("fun",ls))] *) val thms = Opentheory.read_article input {thms=asms,consts=consts,types=types} If all goes well, thms should be bound to a list of theorems proved by the article. > > Cheers, > > Joe > > On Sun, Jan 9, 2011 at 5:43 AM, Ramana Kumar wrote: >> I have added a preliminary version of an article reader to HOL4 >> (hol.sf.net, svn r8839) >> >> Which other proof assistants have readers, by the way? Is there a list >> somewhere? >> >> On Sat, Jan 8, 2011 at 5:54 PM, Ramana Kumar wrote: >>> Does anyone know if there's an article reader for HOL4? >>> Or, in fact, which theorem provers have article readers, and where can >>> they be found? >>> I'm thinking if there is none for HOL4 I should write it, and then put >>> it with the HOL4 sources - or should it come with the opentheory? >>> >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Sun Jan 9 21:50:02 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sun, 9 Jan 2011 21:50:02 +0000 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: On Sun, Jan 9, 2011 at 8:43 PM, Ramana Kumar wrote: > On Sun, Jan 9, 2011 at 7:08 PM, Joe Hurd wrote: >> Hi Ramana, >> >> Thanks for implementing this: HOL4 is now the first theorem prover >> with an article reader! >> >> I'd like to try it out: how do I run it? > > At this stage it's going to break on anything interesting you try it on... > But the basic method would be: > > Build the latest svn version of HOL4 > > In a HOL4 session, do: > > val input = (* article file, e.g. TextIO.openIn("/path/to/file.art") *) > val asms = (* net of theorems the article depends on, you can use > Opentheory.thmsFromList ls to create this from a list of HOL4 theorems *) > val consts = (* dictionary of constants the article depends on, keyed by their > name, and represented by functions (hol_type -> term). > You can use Opentheory.constsFromList ls, > e.g. constsFromList [("=",fn ty => Term.mk_const("=",ty))] *) > val types = (* dictionary of types the article depends on, keyed by their > names, and represented by functions (hol_type list -> hol-type). > You can use Opentheory.typesFromList ls, > e.g. typesFromList [("->",fn ls => Type.mk_type("fun",ls))] *) > val thms = Opentheory.read_article input {thms=asms,consts=consts,types=types} > > If all goes well, thms should be bound to a list of theorems proved by > the article. I'm starting to discover that this design may be quite broken... articles can depend on assumption expressed using constants and types defined by the article - how am I supposed to pass those in as theorems to read_article? For example the bool-1.0 package has an axiom |- !t. (\x. t x) = t, which is provable in HOL using HOL's definition of !, but the package wants that theorem for it's own version of ! that it defines itself... I think I must have fundamentally misunderstood how articles are supposed to be used. I guess instead of actually defining new constants while reading an article, one should just pass in constants that you want to act like the ones the article is going to define, and pass in theorems you already know about them for the article's axioms..? What's the difference between an assumption and an axiom? opentheory info --summary gives lists of input type operators, input constants, assumptions, defined constants, axioms, and theorems. My new understanding of how to deal with these is as follows: input type operators: existing type operators input constants: existing constants assumptions: unknown? actually these are probably just theorems about the input constants, which can be supplied defined constants: existing constants that you want the article to provide you more theorems about axioms: theorems you need to supply about the defined constants theorems: theorems you get by reading the article Does this make sense? I will try reworking my reader to act like this... > >> >> Cheers, >> >> Joe >> >> On Sun, Jan 9, 2011 at 5:43 AM, Ramana Kumar wrote: >>> I have added a preliminary version of an article reader to HOL4 >>> (hol.sf.net, svn r8839) >>> >>> Which other proof assistants have readers, by the way? Is there a list >>> somewhere? >>> >>> On Sat, Jan 8, 2011 at 5:54 PM, Ramana Kumar wrote: >>>> Does anyone know if there's an article reader for HOL4? >>>> Or, in fact, which theorem provers have article readers, and where can >>>> they be found? >>>> I'm thinking if there is none for HOL4 I should write it, and then put >>>> it with the HOL4 sources - or should it come with the opentheory? >>>> >>> >>> _______________________________________________ >>> opentheory-users mailing list >>> opentheory-users at gilith.com >>> http://www.gilith.com/mailman/listinfo/opentheory-users >>> >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > From ramana.kumar at gmail.com Sun Jan 9 23:02:37 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sun, 9 Jan 2011 23:02:37 +0000 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: Articles live in their own abstract world of higher order logic, and the goal of an article reader is to interpret this abstract world in the reader's world then follow the instructions in the article to extend it. The reader's world may already include definitions and theorems that the article's world doesn't (although if it's the other way around, the reader can't use the article). In that case when the article defines/proves something, the reader just supplies its existing constant/theorem. Here's what I'm thinking the reader type should look like: val read_article : TextIO.instream -> {input_types : (string, hol_type list -> hol_type) dict input_consts : (string, hol_type -> term) dict assumptions : thm net output_types : (string, {axiom:thm, args:hol_type list, rep:string, abs:string} -> {rep_abs:thm, abs_rep:thm, rep:term, abs:term}) dict output_consts : (string, term -> {const:term, def:thm}) dict axioms : (term list * term) -> thm } -> Thm.thm list Explanation of the fields: (By types I mean type operators, where hol_types are understood as operators that take no arguments.) Input types are types the article depends on and doesn't define. The input_types field is a map from the article's names for these types to hol_types. Input consts are constants the article depends on and doesn't define. The input_consts field is a map from the article's names for these constants to constant terms. Assumptions are theorems about the input types and input consts (only; any exceptions?) that the article needs to use. The assumptions field is a net of theorems indexed by their conclusions that provides these theorems. Output types are types that the article will define. The output_types field is a map from the article's names for these types to functions. Each of these function performs an action equivalent to defining the new type; if the reader's world doesn't already contain the type, the function defines it and returns some information about it, and if the reader's world already includes the type, the function just returns the information about the existing type. Each function is provided the type axiom, a list of arguments for the type in order, and the desired names of the rep and abs constants. It must return the rep and abs constants and the type bijection theorems. If the type doesn't exist in the reader's world, this is straightforward: just make a new type definition. If the type already exists, the reader might have to do some renaming (or even define a new equivalent type to get the argument order right). Passing back abs and rep terms that don't have the desired names is fine: those names are article world names, so the reader just has to make sure whenever the article turns a constant with that name into a term, it gets back the right term. Output consts are constants that the article will define. The output_consts field is a map from the article's names for these constants to functions. Each of these functions performs an action equivalent to defining the new constant. Each function gets the term the constant should be defined as and must return the constant and a theorem saying it's equal to that term. If the reader's world already contains the constant, under an equivalent definition, making that theorem could require some reader-side proving. As with types, the string that is the article name and the actual (#1 o dest_const) name of the term can differ, as long as the article can never tell. Axioms are theorems about the defined constants that the article needs to use but doesn't prove. If the reader's world already contained the defined constants, then it might also already contain these theorems. If the reader's world did not, then it will need to provide these theorems perhaps by proving them or by calling make_axiom. The axioms field is a function from the desired (hypothesis,conclusion) pairs to theorems. It is guaranteed to be called on pairs only after the constants appearing in those pairs have had their definition functions called, so there is a chance that the reader could supply some proof procedures here if it previously actually made new definitions. (The reading of the article could even involve user interaction to prove the axioms.) Am I getting the concepts right now? How would you make this description more accurate? On Sun, Jan 9, 2011 at 9:50 PM, Ramana Kumar wrote: > On Sun, Jan 9, 2011 at 8:43 PM, Ramana Kumar wrote: >> On Sun, Jan 9, 2011 at 7:08 PM, Joe Hurd wrote: >>> Hi Ramana, >>> >>> Thanks for implementing this: HOL4 is now the first theorem prover >>> with an article reader! >>> >>> I'd like to try it out: how do I run it? >> >> At this stage it's going to break on anything interesting you try it on... >> But the basic method would be: >> >> Build the latest svn version of HOL4 >> >> In a HOL4 session, do: >> >> val input = (* article file, e.g. TextIO.openIn("/path/to/file.art") *) >> val asms = (* net of theorems the article depends on, you can use >> Opentheory.thmsFromList ls to create this from a list of HOL4 theorems *) >> val consts = (* dictionary of constants the article depends on, keyed by their >> name, and represented by functions (hol_type -> term). >> You can use Opentheory.constsFromList ls, >> e.g. constsFromList [("=",fn ty => Term.mk_const("=",ty))] *) >> val types = (* dictionary of types the article depends on, keyed by their >> names, and represented by functions (hol_type list -> hol-type). >> You can use Opentheory.typesFromList ls, >> e.g. typesFromList [("->",fn ls => Type.mk_type("fun",ls))] *) >> val thms = Opentheory.read_article input {thms=asms,consts=consts,types=types} >> >> If all goes well, thms should be bound to a list of theorems proved by >> the article. > > I'm starting to discover that this design may be quite broken... > articles can depend on assumption expressed using constants and types > defined by the article - how am I supposed to pass those in as > theorems to read_article? For example the bool-1.0 package has an > axiom |- !t. (\x. t x) = t, which is provable in HOL using HOL's > definition of !, but the package wants that theorem for it's own > version of ! that it defines itself... > > I think I must have fundamentally misunderstood how articles are > supposed to be used. I guess instead of actually defining new > constants while reading an article, one should just pass in constants > that you want to act like the ones the article is going to define, and > pass in theorems you already know about them for the article's > axioms..? > > What's the difference between an assumption and an axiom? > opentheory info --summary gives lists of input type operators, input > constants, assumptions, defined constants, axioms, and theorems. > My new understanding of how to deal with these is as follows: > input type operators: existing type operators > input constants: existing constants > assumptions: unknown? actually these are probably just theorems about > the input constants, which can be supplied > defined constants: existing constants that you want the article to > provide you more theorems about > axioms: theorems you need to supply about the defined constants > theorems: theorems you get by reading the article > > Does this make sense? > I will try reworking my reader to act like this... > >> >>> >>> Cheers, >>> >>> Joe >>> >>> On Sun, Jan 9, 2011 at 5:43 AM, Ramana Kumar wrote: >>>> I have added a preliminary version of an article reader to HOL4 >>>> (hol.sf.net, svn r8839) >>>> >>>> Which other proof assistants have readers, by the way? Is there a list >>>> somewhere? >>>> >>>> On Sat, Jan 8, 2011 at 5:54 PM, Ramana Kumar wrote: >>>>> Does anyone know if there's an article reader for HOL4? >>>>> Or, in fact, which theorem provers have article readers, and where can >>>>> they be found? >>>>> I'm thinking if there is none for HOL4 I should write it, and then put >>>>> it with the HOL4 sources - or should it come with the opentheory? >>>>> >>>> >>>> _______________________________________________ >>>> opentheory-users mailing list >>>> opentheory-users at gilith.com >>>> http://www.gilith.com/mailman/listinfo/opentheory-users >>>> >>> >>> _______________________________________________ >>> opentheory-users mailing list >>> opentheory-users at gilith.com >>> http://www.gilith.com/mailman/listinfo/opentheory-users >>> >> > From joe at gilith.com Mon Jan 10 00:17:36 2011 From: joe at gilith.com (Joe Hurd) Date: Sun, 9 Jan 2011 16:17:36 -0800 Subject: [opentheory-users] order of arguments to eqMp In-Reply-To: References: Message-ID: Hi Ramana, Documentation bug - now fixed. Good catch. Cheers, Joe On Sun, Jan 9, 2011 at 1:12 PM, Ramana Kumar wrote: > Is the documentation of the file format here > http://www.gilith.com/research/opentheory/article.html#eqMpCommand > correct? > My reader appears to be saying that the article file corresponding to > bool-1.0 wants |- phi to be popped before |- phi' = psi > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Mon Jan 10 00:30:16 2011 From: joe at gilith.com (Joe Hurd) Date: Sun, 9 Jan 2011 16:30:16 -0800 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: Hi Ramana, I think this description you have here is quite accurate: I only have a few minor places where I might improve it. > In > that case when the article defines/proves something, the reader just supplies > its existing constant/theorem. The reader is only supposed to provide existing things to meet input type operators, constants and assumptions. So for example you would never read the base-1.0 theory into HOL4, because it already has definitions for the Boolean operators. However, it might make sense to read in the theory list-replicate-1.0 which defines and proves properties about a list replicate function (assuming that HOL4 doesn't already define this function). It might also make sense to read in the theory list-map-thm-1.0, which doesn't define anything, but proves a bunch of theorems about the list map function. > Axioms are theorems about the defined constants that the article needs to use > but doesn't prove. Axioms are simply assumptions made about type operators and constants that the article defines, and can be safely ignored because HOL4 already has versions of them for its own definitions of Booleans and natural numbers. Does that help? Cheers, Joe From joe at gilith.com Mon Jan 10 00:38:18 2011 From: joe at gilith.com (Joe Hurd) Date: Sun, 9 Jan 2011 16:38:18 -0800 Subject: [opentheory-users] parsing article information In-Reply-To: References: Message-ID: Hi Ramana, >> opentheory info --summary is supposed to generate article summaries in >> a human readable form: as of now there is no machine-readable version >> of it other than the article file. > > Will there be? I can probably get opentheory to spit one out by > catching it just before it prints the human-readable version and > sending whatever data structures it is using to a different printer. I was planning on reusing the article format to output the summaries in machine-readable form at some point. I'd be interested in knowing what your application is for this. >> You are correct: the (as yet documented) show tags in a theory >> determines how the namespaces get transformed as names are printed. To >> see a pure version remove all show tags or just run opentheory info >> --summary directly on the article file. > > If I generate the article file with opentheory, though, the namespace > information is there. How do I get a pure article file for say > bool-1.0? When I said "pure" I meant with no namespace transformation, so all names print with their fully-qualified name in the OpenTheory namespace. What did you think of my suggestion of constructing a mapping between fully-qualified names in the OpenTheory namespace and HOL4 names, as I did for HOL Light? Cheers, Joe From ramana.kumar at gmail.com Mon Jan 10 02:33:54 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 02:33:54 +0000 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 12:30 AM, Joe Hurd wrote: > Hi Ramana, > > I think this description you have here is quite accurate: I only have > a few minor places where I might improve it. > >> In >> that case when the article defines/proves something, the reader just supplies >> its existing constant/theorem. > > The reader is only supposed to provide existing things to meet input > type operators, constants and assumptions. So for example you would > never read the base-1.0 theory into HOL4, because it already has > definitions for the Boolean operators. However, it might make sense to > read in the theory list-replicate-1.0 which defines and proves > properties about a list replicate function (assuming that HOL4 doesn't > already define this function). It might also make sense to read in the > theory list-map-thm-1.0, which doesn't define anything, but proves a > bunch of theorems about the list map function. Well although I see the usefulness of reading articles that mainly give you new constants/theorems that you don't already have versions of in your proof assistant, I think the more general approach where you might read base-1.0 into HOL4 is worth pursuing because base-1.0 might say just a few different or interesting things about basic things that HOL4 has its own versions of. The most useful way to read base-1.0 in is to make it "define" your already-defined constants by simulating the effect of the definition (proving the necessary theorem whenever base-1.0 defines things slightly differently etc.). In the end you get a bunch of theorems many of which you already have but some of which you might not. And importantly, these will be in the exact right format and number to pass along to later opentheory articles that depend on base-1.0. > >> Axioms are theorems about the defined constants that the article needs to use >> but doesn't prove. > > Axioms are simply assumptions made about type operators and constants > that the article defines, and can be safely ignored because HOL4 > already has versions of them for its own definitions of Booleans and > natural numbers. But you can't just ignore them because you need to really provide a theorem for every axiom when you're reading the article, otherwise you won't get any theorems back. > > Does that help? Well, I'm glad you think my description was quite accurate :) I'm a little confused by what you said about axioms though. > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 02:38:11 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 02:38:11 +0000 Subject: [opentheory-users] parsing article information In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 12:38 AM, Joe Hurd wrote: > Hi Ramana, > >>> opentheory info --summary is supposed to generate article summaries in >>> a human readable form: as of now there is no machine-readable version >>> of it other than the article file. >> >> Will there be? I can probably get opentheory to spit one out by >> catching it just before it prints the human-readable version and >> sending whatever data structures it is using to a different printer. > > I was planning on reusing the article format to output the summaries > in machine-readable form at some point. I'd be interested in knowing > what your application is for this. > >>> You are correct: the (as yet documented) show tags in a theory >>> determines how the namespaces get transformed as names are printed. To >>> see a pure version remove all show tags or just run opentheory info >>> --summary directly on the article file. >> >> If I generate the article file with opentheory, though, the namespace >> information is there. How do I get a pure article file for say >> bool-1.0? > > When I said "pure" I meant with no namespace transformation, so all > names print with their fully-qualified name in the OpenTheory > namespace. > > What did you think of my suggestion of constructing a mapping between > fully-qualified names in the OpenTheory namespace and HOL4 names, as I > did for HOL Light? At first I didn't understand why you would want such a mapping, but with my new understanding of articles and article readers, it makes perfect sense to have a such a mapping and indeed I plan to use one now, and definitely want the fully qualified names in the article. > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 02:39:58 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 02:39:58 +0000 Subject: [opentheory-users] parsing article information In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 12:38 AM, Joe Hurd wrote: > Hi Ramana, > >>> opentheory info --summary is supposed to generate article summaries in >>> a human readable form: as of now there is no machine-readable version >>> of it other than the article file. >> >> Will there be? I can probably get opentheory to spit one out by >> catching it just before it prints the human-readable version and >> sending whatever data structures it is using to a different printer. > > I was planning on reusing the article format to output the summaries > in machine-readable form at some point. I'd be interested in knowing > what your application is for this. My immediate application would be to check that my reader is correct. If I can easily get the set of (term list, term) pairs representing theorems that an article is supposed to produce from opentheory, then I can check that after reading the article I actually did produce those theorems. > >>> You are correct: the (as yet documented) show tags in a theory >>> determines how the namespaces get transformed as names are printed. To >>> see a pure version remove all show tags or just run opentheory info >>> --summary directly on the article file. >> >> If I generate the article file with opentheory, though, the namespace >> information is there. How do I get a pure article file for say >> bool-1.0? > > When I said "pure" I meant with no namespace transformation, so all > names print with their fully-qualified name in the OpenTheory > namespace. > > What did you think of my suggestion of constructing a mapping between > fully-qualified names in the OpenTheory namespace and HOL4 names, as I > did for HOL Light? > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Mon Jan 10 03:04:45 2011 From: joe at gilith.com (Joe Hurd) Date: Sun, 9 Jan 2011 19:04:45 -0800 Subject: [opentheory-users] parsing article information In-Reply-To: References: Message-ID: Hi Ramana, > My immediate application would be to check that my reader is correct. > If I can easily get the set of (term list, term) pairs representing > theorems that an article is supposed to produce from opentheory, then > I can check that after reading the article I actually did produce > those theorems. Perhaps until there is a better machine-readable format you could use the "thm" commands in the article that you're reading to simulate this. If you store the "hyp" and "concl" arguments of each "thm" command you read, then this is precisely the set of theorems that the article is supposed to generate. Cheers, Joe From joe at gilith.com Mon Jan 10 03:20:36 2011 From: joe at gilith.com (Joe Hurd) Date: Sun, 9 Jan 2011 19:20:36 -0800 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: Hi Ramana, > Well although I see the usefulness of reading articles that mainly give you new > constants/theorems that you don't already have versions of in your proof > assistant, I think the more general approach where you might read base-1.0 into > HOL4 is worth pursuing because base-1.0 might say just a few different or > interesting things about basic things that HOL4 has its own versions of. ?The > most useful way to read base-1.0 in is to make it "define" your already-defined > constants by simulating the effect of the definition (proving the necessary > theorem whenever base-1.0 defines things slightly differently etc.). In the end > you get a bunch of theorems many of which you already have but some of which > you might not. And importantly, these will be in the exact right format and > number to pass along to later opentheory articles that depend on base-1.0. I can appreciate your reasons for wanting to import articles this way, but (as you say) there is an additional implementation cost of managing clashing definitions. My comment about ignoring axioms only applies when reading articles without clashing definitions. In your more general case I believe you can simply treat axioms like assumptions, because the distinction between defined and input has disappeared. Cheers, Joe From ramana.kumar at gmail.com Mon Jan 10 08:17:31 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 08:17:31 +0000 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 3:20 AM, Joe Hurd wrote: > Hi Ramana, > >> Well although I see the usefulness of reading articles that mainly give you new >> constants/theorems that you don't already have versions of in your proof >> assistant, I think the more general approach where you might read base-1.0 into >> HOL4 is worth pursuing because base-1.0 might say just a few different or >> interesting things about basic things that HOL4 has its own versions of. ?The >> most useful way to read base-1.0 in is to make it "define" your already-defined >> constants by simulating the effect of the definition (proving the necessary >> theorem whenever base-1.0 defines things slightly differently etc.). In the end >> you get a bunch of theorems many of which you already have but some of which >> you might not. And importantly, these will be in the exact right format and >> number to pass along to later opentheory articles that depend on base-1.0. > > I can appreciate your reasons for wanting to import articles this way, > but (as you say) there is an additional implementation cost of > managing clashing definitions. All right. I'd love to see how you envision the purpose of opentheory and articles and how they would interact with various proof assistants, if you've written that down anywhere I might not have seen yet. I know there are those two papers on your website. > > My comment about ignoring axioms only applies when reading articles > without clashing definitions. In your more general case I believe you > can simply treat axioms like assumptions, because the distinction > between defined and input has disappeared. It's still confusing, and what to make sure I'm not misunderstanding something significant. Suppose you're reading an article without any clashing definitions, i.e. any constant the article wants to define is not already defined in the reader's world. The axioms of the article will be about those undefined constants. When the reader comes to process the axiom command, it needs to provide a theorem. How is the reader supposed to have a theorem about a constant it hasn't yet defined? Presumably before it comes to the axiom command, it will have processed the definitional commands so the constants will by then be defined, but since the article doesn't prove the axioms, the theorems won't be there - the article reader would have to delegate proving of the axiom off to some proof procedure (possibly interactive), or would have to return a continuation that takes the axiom theorem and continues processing the file, sort of leaving you with a function from axioms to theorems, but not quite (the main problem here is that HOL4's definition mechanism is stateful; if it weren't you probably could just get such a plain function from theorems to theorems as the result of reading an article, but since it's stateful it's more obvious to use something like continuations). Neither of these options are really described by just ignoring the axiom... > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 08:45:31 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 08:45:31 +0000 Subject: [opentheory-users] axioms Message-ID: Is an article allowed to call the axiom command on a theorem the article itself has already proved? Presumably any articles in gilith won't do that though...? From ramana.kumar at gmail.com Mon Jan 10 15:21:39 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 15:21:39 +0000 Subject: [opentheory-users] quoted strings Message-ID: It appears that the quoted string command allows (requires) special characters to be escaped. For example, bool.art from bool-1.0 contains the following line, literally: "Data.Bool./\\" Is that name 'Data.Bool./\' or 'Data.Bool./\\'? The article format specification is at best unclear about this. Reading the specification literally, it looks like you get a command "s" (the quotation marks are literal characters and between them is a variable) and interpret it as Name s, not Name (parse_as_string s). Of course it does say that the variable stands for a string, and maybe that's supposed to be the clue that it might contain character escapes... From ramana.kumar at gmail.com Mon Jan 10 15:55:25 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 15:55:25 +0000 Subject: [opentheory-users] arguments to eqMp Message-ID: There may be another bug in the documentation (or implementation) to do with eqMp. I believe bool.art from bool-1.0 tries to do an eqMp on theorems with these conclusions: x = x (T ? (x = x)) ? (x = x) but the second theorem is the reflection of what you would expect given the documentation. On Mon, Jan 10, 2011 at 12:17 AM, Joe Hurd wrote: > Hi Ramana, > > Documentation bug - now fixed. Good catch. > > Cheers, > > Joe > > On Sun, Jan 9, 2011 at 1:12 PM, Ramana Kumar wrote: >> Is the documentation of the file format here >> http://www.gilith.com/research/opentheory/article.html#eqMpCommand >> correct? >> My reader appears to be saying that the article file corresponding to >> bool-1.0 wants |- phi to be popped before |- phi' = psi >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 15:59:30 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 15:59:30 +0000 Subject: [opentheory-users] arguments to eqMp In-Reply-To: References: Message-ID: I think it's an implementation (or package) bug, because the same article file also tries to do eqMp on these: T ? T (T ? T) ? (((?x. x) = (?x. x)) ? T) On Mon, Jan 10, 2011 at 3:55 PM, Ramana Kumar wrote: > There may be another bug in the documentation (or implementation) to > do with eqMp. > I believe bool.art from bool-1.0 tries to do an eqMp on theorems with > these conclusions: > x = x > (T ? (x = x)) ? (x = x) > but the second theorem is the reflection of what you would expect > given the documentation. > On Mon, Jan 10, 2011 at 12:17 AM, Joe Hurd wrote: >> Hi Ramana, >> >> Documentation bug - now fixed. Good catch. >> >> Cheers, >> >> Joe >> >> On Sun, Jan 9, 2011 at 1:12 PM, Ramana Kumar wrote: >>> Is the documentation of the file format here >>> http://www.gilith.com/research/opentheory/article.html#eqMpCommand >>> correct? >>> My reader appears to be saying that the article file corresponding to >>> bool-1.0 wants |- phi to be popped before |- phi' = psi >>> >>> _______________________________________________ >>> opentheory-users mailing list >>> opentheory-users at gilith.com >>> http://www.gilith.com/mailman/listinfo/opentheory-users >>> >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > From ramana.kumar at gmail.com Mon Jan 10 16:02:46 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 16:02:46 +0000 Subject: [opentheory-users] arguments to eqMp In-Reply-To: References: Message-ID: All right now I'm starting to suspect it's not to do with eqMp at all... T ? (x = x) (T ? ((x = x) ? T)) ? ((x = x) ? T) Perhaps the deductAntisym documentation is wrong? (Or my implementation of deductAntisym is wrong - I will check now...) On Mon, Jan 10, 2011 at 3:59 PM, Ramana Kumar wrote: > I think it's an implementation (or package) bug, because the same > article file also tries to do eqMp on these: > T ? T > (T ? T) ? (((?x. x) = (?x. x)) ? T) > > On Mon, Jan 10, 2011 at 3:55 PM, Ramana Kumar wrote: >> There may be another bug in the documentation (or implementation) to >> do with eqMp. >> I believe bool.art from bool-1.0 tries to do an eqMp on theorems with >> these conclusions: >> x = x >> (T ? (x = x)) ? (x = x) >> but the second theorem is the reflection of what you would expect >> given the documentation. >> On Mon, Jan 10, 2011 at 12:17 AM, Joe Hurd wrote: >>> Hi Ramana, >>> >>> Documentation bug - now fixed. Good catch. >>> >>> Cheers, >>> >>> Joe >>> >>> On Sun, Jan 9, 2011 at 1:12 PM, Ramana Kumar wrote: >>>> Is the documentation of the file format here >>>> http://www.gilith.com/research/opentheory/article.html#eqMpCommand >>>> correct? >>>> My reader appears to be saying that the article file corresponding to >>>> bool-1.0 wants |- phi to be popped before |- phi' = psi >>>> >>>> _______________________________________________ >>>> opentheory-users mailing list >>>> opentheory-users at gilith.com >>>> http://www.gilith.com/mailman/listinfo/opentheory-users >>>> >>> >>> _______________________________________________ >>> opentheory-users mailing list >>> opentheory-users at gilith.com >>> http://www.gilith.com/mailman/listinfo/opentheory-users >>> >> > From ramana.kumar at gmail.com Mon Jan 10 16:06:00 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 16:06:00 +0000 Subject: [opentheory-users] arguments to eqMp In-Reply-To: References: Message-ID: yeah it was my implementation of deductAntisym - sorry for all the noise! On Mon, Jan 10, 2011 at 4:02 PM, Ramana Kumar wrote: > All right now I'm starting to suspect it's not to do with eqMp at all... > T ? (x = x) > (T ? ((x = x) ? T)) ? ((x = x) ? T) > Perhaps the deductAntisym documentation is wrong? > (Or my implementation of deductAntisym is wrong - I will check now...) > > On Mon, Jan 10, 2011 at 3:59 PM, Ramana Kumar wrote: >> I think it's an implementation (or package) bug, because the same >> article file also tries to do eqMp on these: >> T ? T >> (T ? T) ? (((?x. x) = (?x. x)) ? T) >> >> On Mon, Jan 10, 2011 at 3:55 PM, Ramana Kumar wrote: >>> There may be another bug in the documentation (or implementation) to >>> do with eqMp. >>> I believe bool.art from bool-1.0 tries to do an eqMp on theorems with >>> these conclusions: >>> x = x >>> (T ? (x = x)) ? (x = x) >>> but the second theorem is the reflection of what you would expect >>> given the documentation. >>> On Mon, Jan 10, 2011 at 12:17 AM, Joe Hurd wrote: >>>> Hi Ramana, >>>> >>>> Documentation bug - now fixed. Good catch. >>>> >>>> Cheers, >>>> >>>> Joe >>>> >>>> On Sun, Jan 9, 2011 at 1:12 PM, Ramana Kumar wrote: >>>>> Is the documentation of the file format here >>>>> http://www.gilith.com/research/opentheory/article.html#eqMpCommand >>>>> correct? >>>>> My reader appears to be saying that the article file corresponding to >>>>> bool-1.0 wants |- phi to be popped before |- phi' = psi >>>>> >>>>> _______________________________________________ >>>>> opentheory-users mailing list >>>>> opentheory-users at gilith.com >>>>> http://www.gilith.com/mailman/listinfo/opentheory-users >>>>> >>>> >>>> _______________________________________________ >>>> opentheory-users mailing list >>>> opentheory-users at gilith.com >>>> http://www.gilith.com/mailman/listinfo/opentheory-users >>>> >>> >> > From joe at gilith.com Mon Jan 10 17:14:33 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 09:14:33 -0800 Subject: [opentheory-users] axioms In-Reply-To: References: Message-ID: Hi Ramana, Yes, that's a legal command, but I don't expect to see it used in the theories currently uploaded. Cheers, Joe On Mon, Jan 10, 2011 at 12:45 AM, Ramana Kumar wrote: > Is an article allowed to call the axiom command on a theorem the > article itself has already proved? > > Presumably any articles in gilith won't do that though...? > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 17:35:30 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 17:35:30 +0000 Subject: [opentheory-users] Fwd: [Hol-checkins] SF.net SVN: hol:[8845] HOL/src/opentheory In-Reply-To: References: Message-ID: My new implementation of the article reader for HOL4 (svn r8845) now successfully reads bool-1.0 (although I didn't check all the theorems were there - it looks reasonable, though). In the HOL repo, src/opentheory/selftest.sml is an example of how to use the reader, and src/opentheory/Opentheory.sig has some descriptive comments. ---------- Forwarded message ---------- From: Date: Mon, Jan 10, 2011 at 5:32 PM Subject: [Hol-checkins] SF.net SVN: hol:[8845] HOL/src/opentheory To: hol-checkins at lists.sf.net Revision: 8845 ? ? ? ? ?http://hol.svn.sourceforge.net/hol/?rev=8845&view=rev Author: ? xrchz Date: ? ? 2011-01-10 17:32:29 +0000 (Mon, 10 Jan 2011) Log Message: ----------- Complete rewrite of Opentheory reader It now successfully reads the package bool-1.0 in the gilith repository, and that is the selftest (only runs if you have opentheory installed). The selftest file is also an example of the work you might need to do to read an opentheory article that defines constants that are already defined in HOL. When the article is only going to define new things, the work would likely be less, although some helper functions (TODO) in the Opentheory module would make it easier. Modified Paths: -------------- ? ?HOL/src/opentheory/Opentheory.sig ? ?HOL/src/opentheory/Opentheory.sml ? ?HOL/src/opentheory/selftest.sml Modified: HOL/src/opentheory/Opentheory.sig =================================================================== --- HOL/src/opentheory/Opentheory.sig ? 2011-01-10 06:01:44 UTC (rev 8844) +++ HOL/src/opentheory/Opentheory.sig ? 2011-01-10 17:32:29 UTC (rev 8845) @@ -1,12 +1,51 @@ ?signature Opentheory = sig - ?type thms ? = Thm.thm Net.net - ?type types ?= (string, Type.hol_type list -> Type.hol_type) Redblackmap.dict - ?type consts = (string, Type.hol_type -> Term.term) Redblackmap.dict - ?val empty_thms ? ? : thms - ?val empty_types ? ?: types - ?val empty_consts ? : consts - ?val thmsFromList ? : Thm.thm list -> thms - ?val typesFromList ?: (string * (Type.hol_type list -> Type.hol_type)) list -> types - ?val constsFromList : (string * (Type.hol_type -> Term.term)) list -> consts - ?val read_article ? : TextIO.instream -> {thms:thms,types:types,consts:consts} -> Thm.thm list +type term = Term.term type hol_type = Type.hol_type type thm = Thm.thm +type ('a,'b) dict = ('a,'b) Redblackmap.dict + +(* maps between OpenTheory names and HOL4 names: *) +type thy_tyop ?= {Thy:string,Tyop:string} +type thy_const = {Thy:string,Name:string} +type 'a to_ot ?= ('a,string) dict +type 'a from_ot= (string,'a) dict +val tyop_to_ot ? : unit -> thy_tyop to_ot +val tyop_from_ot : unit -> thy_tyop from_ot +val const_to_ot ?: unit -> thy_const to_ot +val const_from_ot: unit -> thy_const from_ot + +(* record of data an article reader must provide: *) +type reader = { + ?tyops ?: (string, {axiom:thm, args:hol_type list, rep:string, abs:string} -> + ? ? ? ? ? ? ? ? ? ?{rep_abs:thm, abs_rep:thm, rep:term, abs:term, tyop:thy_tyop}) + ? ? ? ? ? dict, + ?consts : (string, term -> {const:thy_const, def:thm}) dict, + ?axioms : thm Net.net -> (term list * term) -> thm} + +(* +tyops are type operators the article will define, indexed by their OpenTheory +names. Each name is mapped to a function that does something equivalent to +defining the new type. Each function is provided the type axiom, a list of +arguments (type variables) for the type operator in the desired order, and the +OpenTheory names of the rep and abs constants. It must return the new type +operator, the rep and abs constants, and the type bijection theorems. +If axiom = |- P t then these are: + ?abs_rep = |- (!a. abs (rep a) = a) + ?rep_abs = |- (!r. P r = (rep(abs r) = r)) + +consts are constants the article will define, indexed by their OpenTheory +names. Each name is mapped to a function that does something equivalent to +defining the new constant. Each function is provided the right hand side rhs of +the definition and must return the name of the constant and an equational +theorem |- const = rhs. + +axioms are theorems that the article depends on about possibly both input +and output tyops and constants. They are represented by a function that takes +the collection of theorems the article has already proved, represented by a +conclusion-indexed net, and a pair (h,c) representing the desired axiom, and +must return a theorem h |- c. +*) + +val raw_read_article : {tyop_from_ot:thy_tyop from_ot, + ? ? ? ? ? ? ? ? ? ? ? ?const_from_ot:thy_const from_ot} + ? ? ? ? ? -> TextIO.instream -> reader -> thm list +val read_article ? ? : string -> reader -> thm list ?end Modified: HOL/src/opentheory/Opentheory.sml =================================================================== --- HOL/src/opentheory/Opentheory.sml ? 2011-01-10 06:01:44 UTC (rev 8844) +++ HOL/src/opentheory/Opentheory.sml ? 2011-01-10 17:32:29 UTC (rev 8845) @@ -1,221 +1,162 @@ ?structure Opentheory :> Opentheory = struct -val ERR = Feedback.mk_HOL_ERR "Opentheory" +open boolSyntax HolKernel Parse +local open Drule Conv in + ?fun DEDUCT_ANTISYM th1 th2 = + ? ?IMP_ANTISYM_RULE + ? ? ?(DISCH (concl th2) th1) + ? ? ?(DISCH (concl th1) th2) + ?fun absThm (v,tu) = let + ? ?val (t,u) = dest_eq(concl tu) + ? ?val vt = mk_abs(v,t) + ? ?val vu = mk_abs(v,u) + ? ?val vtvu = mk_eq(vt,vu) + ? ?val x = FUN_EQ_CONV vtvu + ? ?val x = CONV_RULE (RAND_CONV (QUANT_CONV (LAND_CONV BETA_CONV))) x + ? ?val x = CONV_RULE (RAND_CONV (QUANT_CONV (RAND_CONV BETA_CONV))) x + ?in EQ_MP (SYM x) (GEN v tu) end +end + +val ERR = mk_HOL_ERR "Opentheory" + ?structure Map = Redblackmap -type thms ? = Thm.thm Net.net -type types ?= (string, Type.hol_type list -> Type.hol_type) Map.dict -type consts = (string, Type.hol_type -> Term.term) Map.dict +type ('a,'b) dict = ('a,'b) Map.dict -val empty_thms ? ? = Net.empty -val empty_types ? ?= Map.mkDict String.compare -val empty_consts ? = Map.mkDict String.compare -val thmsFromList ? = List.foldl (fn (th,n) => Net.insert(Thm.concl th,th) n) empty_thms -val typesFromList ?= Map.fromList String.compare -val constsFromList = Map.fromList String.compare +type thy_tyop ?= {Thy:string,Tyop:string} +type thy_const = {Thy:string,Name:string} +type 'a to_ot ?= ('a,string) dict +type 'a from_ot= (string,'a) dict +fun lex_cmp c (f1,f2) (x1,x2) = + ?case c(f1 x1,f1 x2) of EQUAL => c(f2 x1,f2 x2) | z => z +val thy_tyop_cmp ?= lex_cmp String.compare (#Tyop,#Thy) +val thy_const_cmp = lex_cmp String.compare (#Name,#Thy) +val the_tyop_to_ot ? = ref (Map.mkDict thy_tyop_cmp) +val the_tyop_from_ot = ref (Map.mkDict String.compare) +val the_const_to_ot ?= ref (Map.mkDict thy_const_cmp) +val the_const_from_ot= ref (Map.mkDict String.compare) +fun tyop_to_ot() ? = !the_tyop_to_ot +fun tyop_from_ot() = !the_tyop_from_ot +fun const_to_ot() ?= !the_const_to_ot +fun const_from_ot()= !the_const_from_ot ?datatype object ?= ONum of int ?| OName of string ?| OList of object list -| OTypeOp of string -| OType of Type.hol_type -| OConst of string -| OVar of Term.term -| OTerm of Term.term -| OThm of Thm.thm +| OTypeOp of thy_tyop +| OType of hol_type +| OConst of thy_const +| OVar of term +| OTerm of term +| OThm of thm -datatype command -= Num of int -| Name of string -| AbsTerm -| AbsThm -| AppTerm -| AppThm -| Assume -| Axiom -| BetaConv -| Cons -| Const -| ConstTerm -| DeductAntisym -| Def -| DefineConst -| DefineTypeOp -| EqMp -| Nil -| OpType -| Pop -| Ref -| Refl -| Remove -| Subst -| Thm -| TypeOp -| Var -| VarTerm -| VarType +type reader = + ? {tyops ?: (string, {axiom:thm, args:hol_type list, rep:string, abs:string} -> + ? ? ? ? ? ? ? ? ? ? ?{rep_abs:thm, abs_rep:thm, rep:term, abs:term, tyop:thy_tyop}) + ? ? ? ? ? ? dict, + ? ?consts : (string, term -> {const:thy_const, def:thm}) dict, + ? ?axioms : thm Net.net -> (term list * term) -> thm} -fun st_ (st,{stack,dict,thms}) = {stack=st,dict=dict,thms=thms} -fun push (ob,state) = st_ (ob::(#stack state),state) - -fun find_thm thms (h,c) = let - ?val candidates = Net.index c thms - ?fun equal thm = let - ? ?val c' = Thm.concl thm - ? ?val thm' = Drule.PART_MATCH Lib.I thm (#2(boolSyntax.strip_forall c)) - ?in Lib.set_eq h (Thm.hyp thm') end handle Feedback.HOL_ERR _ => false - ?val SOME th = List.find equal candidates -in th end - -fun find_const consts (n,t) = Map.find(consts,n) t -handle Map.NotFound => Term.mk_const(n,t) -handle Feedback.HOL_ERR _ => raise ERR "find_const" ("need "^n^" of type "^(Parse.type_to_string t)) - -local open Thm Drule in -fun DEDUCT_ANTISYM th1 th2 = - ?IMP_ANTISYM_RULE - ? ?(DISCH (concl th1) th2) - ? ?(DISCH (concl th2) th1) +fun st_(st,{stack,dict,thms}) = {stack=st,dict=dict,thms=thms} +fun push (ob,st) = st_(ob::(#stack st),st) +local open Substring in + ?val trimlr = fn s => string(trimr 1 (triml 1 (full s))) + ?val trimr ?= fn s => string(trimr 1 (full s)) ?end -val unOTermls = List.map (fn OTerm t => t) -val unOTypels = List.map (fn OType t => t) -val unONamels = List.map (fn OName n => n) - -fun find_type types (t,ls) = let - ?val ls = unOTypels ls -in - ?(Map.find(types,t)) ls - ?handle Map.NotFound => let - ? ?val s = Parse.type_to_string(Type.mk_type(t,ls)) - ? ?handle Feedback.HOL_ERR _ => - ? ?(* PolyML.makestring (t, (Map.listItems types)) *) - ? ?("TyOp = "^t^", Args = "^(String.concatWith ", " (List.map Parse.type_to_string ls))) - ?in raise ERR "find_type" ("need "^s) end -end - -exception Comment - -fun - ?parse_line "absTerm" ? ? ? = AbsTerm -| parse_line "absThm" ? ? ? ?= AbsThm -| parse_line "appTerm" ? ? ? = AppTerm -| parse_line "appThm" ? ? ? ?= AppThm -| parse_line "assume" ? ? ? ?= Assume -| parse_line "axiom" ? ? ? ? = Axiom -| parse_line "betaConv" ? ? ?= BetaConv -| parse_line "cons" ? ? ? ? ?= Cons -| parse_line "const" ? ? ? ? = Const -| parse_line "constTerm" ? ? = ConstTerm -| parse_line "deductAntisym" = DeductAntisym -| parse_line "def" ? ? ? ? ? = Def -| parse_line "defineConst" ? = DefineConst -| parse_line "defineTypeOp" ?= DefineTypeOp -| parse_line "eqMp" ? ? ? ? ?= EqMp -| parse_line "nil" ? ? ? ? ? = Nil -| parse_line "opType" ? ? ? ?= OpType -| parse_line "pop" ? ? ? ? ? = Pop -| parse_line "ref" ? ? ? ? ? = Ref -| parse_line "refl" ? ? ? ? ?= Refl -| parse_line "remove" ? ? ? ?= Remove -| parse_line "subst" ? ? ? ? = Subst -| parse_line "thm" ? ? ? ? ? = Thm -| parse_line "typeOp" ? ? ? ?= TypeOp -| parse_line "var" ? ? ? ? ? = Var -| parse_line "varTerm" ? ? ? = VarTerm -| parse_line "varType" ? ? ? = VarType -| parse_line s = let - ? ?val c = String.sub(s,0) - ?in if c = #"\"" then Name (String.substring(s,1,String.size s -2)) else - ? ? if Char.isDigit c then Num (Option.valOf (Int.fromString s)) - ? ? else raise Comment - ?end - -fun read_article file {types,consts,thms} = let - ?val find_asm ? = find_thm thms - ?val find_const = find_const consts - ?val find_type ?= find_type types - ?fun f (Num i) ?st = push(ONum i,st) - ? ?| f (Name s) st = push(OName s,st) - ? ?| f AbsTerm ?(st as {stack=OTerm b::OVar v::os,...}) ?= st_(OTerm(Term.mk_abs(v,b))::os,st) - ? ?| f AppTerm ?(st as {stack=OTerm x::OTerm f::os,...}) = st_(OTerm(Term.mk_comb(f,x))::os,st) - ? ?| f AppThm ? (st as {stack=OThm xy::OThm fg::os,...}) = let - ? ? ? ?val (f,g) = boolSyntax.dest_eq(Thm.concl fg) - ? ? ? ?val (x,y) = boolSyntax.dest_eq(Thm.concl xy) - ? ? ? ?val fxgx ?= Thm.AP_THM fg x - ? ? ? ?val gxgy ?= Thm.AP_TERM g xy - ? ? ?in st_(OThm(Thm.TRANS fxgx gxgy)::os,st) end - ? ?| f Assume ? ? ? ?(st as {stack=OTerm t::os,...}) ? ? ? ? ? = st_(OThm(Thm.ASSUME t)::os,st) - ? ?| f Axiom ? ? ? ? (st as {stack=OTerm t::OList ts::os,...}) = st_(OThm(find_asm(unOTermls ts,t))::os,st) - ? ?| f BetaConv ? ? ?(st as {stack=OTerm t::os,...}) ? ? ? ? ? = st_(OThm(Thm.BETA_CONV t)::os,st) - ? ?| f Cons ? ? ? ? ?(st as {stack=OList t::h::os,...}) ? ? ? ?= st_(OList(h::t)::os,st) - ? ?| f Const ? ? ? ? (st as {stack=OName n::os,...}) ? ? ? ? ? = st_(OConst n::os,st) - ? ?| f ConstTerm ? ? (st as {stack=OType t::OConst c::os,...}) = st_(OTerm(find_const (c,t))::os,st) - ? ?| f DeductAntisym (st as {stack=OThm t1::OThm t2::os,...}) ?= st_(OThm(DEDUCT_ANTISYM t1 t2)::os,st) - ? ?| f Def ? ? ? ? ? {stack=ONum k::x::os,dict,thms} ? ? ? ? ? = {stack=x::os,dict=Map.insert(dict,k,x),thms=thms} - ? ?| f DefineConst ? (st as {stack=OTerm t::OName n::os,...}) ?= let - ? ? ? ?val t = boolSyntax.mk_eq(Term.mk_var(n,Term.type_of t),t) - ? ? ? ?val def = Definition.new_definition(n,t) - ? ? ? ?handle Feedback.HOL_ERR _ => raise ERR "read_article" ("DefineConst "^n^" by "^Parse.term_to_string t^" failed") - ? ? ?in st_(OThm def::OConst n::os,st) end - ? ?| f DefineTypeOp ?(st as {stack=OThm th::OList ls::OName rep::OName abs::OName n::os,...}) = let - ? ? ? ?val ls = unONamels ls - ? ? ? ?val sorted = Lib.sort (Lib.curry (Lib.equal LESS o String.compare)) ls - ? ? ? ?val s = let fun f (a,a',s) = if a = a' then s else let - ? ? ? ? ? ? ? ? ? ? ?val a = Type.mk_vartype a - ? ? ? ? ? ? ? ? ? ? ?val a' = Type.mk_vartype a' - ? ? ? ? ? ? ? ? ? ? ?val op |-> = Lib.|-> infix |-> - ? ? ? ? ? ? ? ? ? ?in (a |-> a')::(a' |-> a)::s end - ? ? ? ? ? ? ? ?in ListPair.foldlEq f [] (ls,sorted) end - ? ? ? ?val th = Thm.INST_TYPE s th - ? ? ? ?val Pt = Thm.concl th - ? ? ? ?val (P,t) = Term.dest_comb(Pt) - ? ? ? ?val th = Thm.EXISTS(boolSyntax.mk_exists(t,Pt),t) th - ? ? ? ?val tyax = Definition.new_type_definition(n,th) - ? ? ? ?val th = Drule.define_new_type_bijections {name=n^"_repfns",ABS=abs,REP=rep,tyax=tyax} - ? ? ? ?val th1 = Drule.SPEC_ALL (Thm.CONJUNCT1 th) - ? ? ? ?val th2 = Drule.SPEC_ALL (Thm.CONJUNCT2 th) - ? ? ?in st_(OThm th2::OThm ?th1::OConst rep::OConst abs::OTypeOp n::os,st) end - ? ?| f EqMp ? (st as {stack=OThm fg::OThm f::os,...}) ? ? = st_(OThm(Thm.EQ_MP fg f)::os,st) - ? ?| f Nil ? ?st ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?= push(OList [],st) - ? ?| f OpType (st as {stack=OList ls::OTypeOp t::os,...}) = st_(OType(find_type(t,ls))::os,st) - ? ?| f Pop ? ?(st as {stack=x::os,...}) ? ? ? ? ? ? ? ? ? = st_(os,st) - ? ?| f Ref ? ?(st as {stack=ONum k::os,dict,...}) ? ? ? ? = st_(Map.find(dict,k)::os,st) - ? ?| f Refl ? (st as {stack=OTerm t::os,...}) ? ? ? ? ? ? = st_(OThm(Thm.REFL t)::os,st) - ? ?| f Remove {stack=ONum k::os,dict,thms} ? ? ? ? ? ? ? ?= let +fun raw_read_article {tyop_from_ot,const_from_ot} input {tyops,consts,axioms} = let + ?val ERR = ERR "read_article" + ?fun unOTermls c = List.map (fn OTerm t => t | _ => raise ERR (c^" failed to pop a list of terms")) + ?fun unOTypels c = List.map (fn OType t => t | _ => raise ERR (c^" failed to pop a list of types")) + ?fun ot_to_const c s = Map.find(const_from_ot,s) + ?handle Map.NotFound => raise ERR (c^": no map from "^s^" to a constant") + ?fun ot_to_tyop ?c s = Map.find(tyop_from_ot ,s) + ?handle Map.NotFound => raise ERR (c^": no map from "^s^" to a type operator") + ?fun f "absTerm"(st as {stack=OTerm b::OVar v::os,...}) = st_(OTerm(mk_abs(v,b))::os,st) + ? ?| f "absThm" (st as {stack=OThm th::OVar v::os,...}) = (st_(OThm(absThm(v,th))::os,st) + ? ? ?handle HOL_ERR e => raise ERR ("absThm: failed with "^format_ERR e)) + ? ?| f "appTerm"(st as {stack=OTerm x::OTerm f::os,...})= st_(OTerm(mk_comb(f,x))::os,st) + ? ?| f "appThm" (st as {stack=OThm xy::OThm fg::os,...})= let + ? ? ? ?val (f,g) = dest_eq(concl fg) + ? ? ? ?val (x,y) = dest_eq(concl xy) + ? ? ? ?val fxgx ?= AP_THM fg x + ? ? ? ?val gxgy ?= AP_TERM g xy + ? ? ?in st_(OThm(TRANS fxgx gxgy)::os,st) end + ? ?| f "assume" ? ? ? (st as {stack=OTerm t::os,...}) ? ? ? ? ?= st_(OThm(ASSUME t)::os,st) + ? ?| f "axiom" ? ? ? ?(st as {stack=OTerm t::OList ts::os,thms,...}) = st_(OThm(axioms thms (unOTermls "axiom" ts,t))::os,st) + ? ?| f "betaConv" ? ? (st as {stack=OTerm t::os,...}) ? ? ? ? ?= st_(OThm(BETA_CONV t)::os,st) + ? ?| f "cons" ? ? ? ? (st as {stack=OList t::h::os,...}) ? ? ? = st_(OList(h::t)::os,st) + ? ?| f "const" ? ? ? ?(st as {stack=OName n::os,...}) ? ? ? ? ?= st_(OConst (ot_to_const "const" n)::os,st) + ? ?| f "constTerm" ? ?(st as {stack=OType Ty::OConst {Thy,Name}::os,...}) + ? ? ? ? ? ? ? ? ? ? = st_(OTerm(mk_thy_const {Ty=Ty,Thy=Thy,Name=Name})::os,st) + ? ?| f "deductAntisym"(st as {stack=OThm t1::OThm t2::os,...}) = st_(OThm(DEDUCT_ANTISYM t1 t2)::os,st) + ? ?| f "def" ? ? ? ? {stack=ONum k::x::os,dict,thms} ? ? ? ? ? = {stack=x::os,dict=Map.insert(dict,k,x),thms=thms} + ? ?| f "defineConst" (st as {stack=OTerm t::OName n::os,...}) ?= let + ? ? ? ?val {const,def} = Map.find(consts,n) t + ? ? ? ?handle Map.NotFound => raise ERR ("defineConst: no map from "^n^" to a definition function") + ? ? ?in st_(OThm def::OConst const::os,st) end + ? ?| f "defineTypeOp" ?(st as {stack=OThm th::OList ls::OName rep::OName abs::OName n::os,...}) = let + ? ? ? ?val ls = List.map (fn OName s => mk_vartype s | _ => raise ERR "defineTypeOp failed to pop a list of names") ls + ? ? ? ?val {abs,rep,abs_rep,rep_abs,tyop} = Map.find(tyops,n) {axiom=th,args=ls,rep=rep,abs=abs} + ? ? ? ?val {Thy,Name,...} = dest_thy_const rep val rep = {Thy=Thy,Name=Name} + ? ? ? ?val {Thy,Name,...} = dest_thy_const abs val abs = {Thy=Thy,Name=Name} + ? ? ?in st_(OThm rep_abs::OThm abs_rep::OConst rep::OConst abs::OTypeOp tyop::os,st) end + ? ?| f "eqMp" ? (st as {stack=OThm f::OThm fg::os,...}) ? ? = (st_(OThm(EQ_MP fg f)::os,st) + ? ? ?handle HOL_ERR _ => raise ERR ("EqMp failed on "^thm_to_string fg^" and "^thm_to_string f)) + ? ?| f "nil" ? ?st ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?= push(OList [],st) + ? ?| f "opType" (st as {stack=OList ls::OTypeOp {Thy,Tyop}::os,...}) + ? ? ? ? ? ? ? = st_(OType(mk_thy_type{Thy=Thy,Tyop=Tyop,Args=unOTypels "opType" ls})::os,st) + ? ?| f "pop" ? ?(st as {stack=x::os,...}) ? ? ? ? ? ? ? ? ? = st_(os,st) + ? ?| f "ref" ? ?(st as {stack=ONum k::os,dict,...}) ? ? ? ? = st_(Map.find(dict,k)::os,st) + ? ?| f "refl" ? (st as {stack=OTerm t::os,...}) ? ? ? ? ? ? = st_(OThm(REFL t)::os,st) + ? ?| f "remove" {stack=ONum k::os,dict,thms} ? ? ? ? ? ? ? ?= let ? ? ? ? val (dict,x) = Map.remove(dict,k) ? ? ? in {stack=x::os,dict=dict,thms=thms} end - ? ?| f Subst ?(st as {stack=OThm th::OList[OList tys,OList tms]::os,...}) = let - ? ? ? ?val tys = List.map (fn OList [OName a, OType t] => {redex=Type.mk_vartype a, residue=t}) tys - ? ? ? ?val tms = List.map (fn OList [OVar v, OTerm t] => {redex=v, residue=t}) tms - ? ? ? ?val th = Thm.INST_TYPE tys th - ? ? ? ?val th = Thm.INST tms th + ? ?| f "subst" ?(st as {stack=OThm th::OList[OList tys,OList tms]::os,...}) = let + ? ? ? ?val tys = List.map (fn OList [OName a, OType t] => {redex=mk_vartype a, residue=t} + ? ? ? ? ? ? ? ? ? ? ? ? ? ? | _ => raise ERR "subst failed to pop a list of [name,type] pairs") tys + ? ? ? ?val tms = List.map (fn OList [OVar v, OTerm t] => {redex=v, residue=t} + ? ? ? ? ? ? ? ? ? ? ? ? ? ? | _ => raise ERR "subst failed to pop a list of [var,term] pairs") tms + ? ? ? ?val th = INST_TYPE tys th + ? ? ? ?val th = INST tms th ? ? ? in st_(OThm th::os,st) end - ? ?| f Thm ? ?{stack=OTerm c::OList ls::OThm th::os,dict,thms} = let - ? ? ? ?val th = Thm.EQ_MP (Thm.ALPHA (Thm.concl th) c) th + ? ?| f "thm" ? ?{stack=OTerm c::OList ls::OThm th::os,dict,thms} = let + ? ? ? ?val th = EQ_MP (ALPHA (concl th) c) th + ? ? ? ?handle HOL_ERR _ => raise ERR "thm: desired conclusion not alpha-equivalent to theorem's conclusion" ? ? ? ? fun ft (OTerm h, th) = let - ? ? ? ? ?val c = Thm.concl th - ? ? ? ? ?val th = Thm.DISCH h th - ? ? ? ? ?val c' = Thm.concl th + ? ? ? ? ?val c = concl th + ? ? ? ? ?val th = DISCH h th + ? ? ? ? ?val c' = concl th ? ? ? ? in - ? ? ? ? ?if Term.aconv c c' then + ? ? ? ? ?if aconv c c' then ? ? ? ? ? ? Drule.ADD_ASSUM h th ? ? ? ? ? else let ? ? ? ? ? ? val (h',_) = boolSyntax.dest_imp c' - ? ? ? ? ? ?val h'h = Thm.ALPHA h' h + ? ? ? ? ? ?val h'h = ALPHA h' h ? ? ? ? ? ? val th = Drule.SUBS_OCCS [([1],h'h)] th ? ? ? ? ? in Drule.UNDISCH th end - ? ? ? ?end + ? ? ? ?end | ft _ = raise ERR "thm failed to pop a list of terms" ? ? ? ? val th = List.foldl ft th ls - ? ? ?in {stack=os,dict=dict,thms=th::thms} end - ? ?| f TypeOp ?(st as {stack=OName n::os,...}) ? ? ? ? ?= st_(OTypeOp n::os,st) - ? ?| f Var ? ? (st as {stack=OType t::OName n::os,...}) = st_(OVar(Term.mk_var(n,t))::os,st) - ? ?| f VarTerm (st as {stack=OVar t::os,...}) ? ? ? ? ? = st_(OTerm t::os,st) - ? ?| f VarType (st as {stack=OName n::os,...}) ? ? ? ? ?= st_(OType(Type.mk_vartype n)::os,st) - ?fun stripnl s = let open Substring in string(trimr 1 (full s)) end - ?fun loop x = case TextIO.inputLine file of - ? ?NONE => x before TextIO.closeIn(file) - ?| SOME line => loop (f (parse_line (stripnl line)) x handle Comment => x) -in #thms (loop {stack=[],dict=Map.mkDict(Int.compare),thms=[]}) end + ? ? ?in {stack=os,dict=dict,thms=Net.insert(concl th,th)thms} end + ? ?| f "typeOp" ?(st as {stack=OName n::os,...}) ? ? ? ? ?= st_(OTypeOp (ot_to_tyop "typeOp" n)::os,st) + ? ?| f "var" ? ? (st as {stack=OType t::OName n::os,...}) = st_(OVar(mk_var(n,t))::os,st) + ? ?| f "varTerm" (st as {stack=OVar t::os,...}) ? ? ? ? ? = st_(OTerm t::os,st) + ? ?| f "varType" (st as {stack=OName n::os,...}) ? ? ? ? ?= st_(OType(mk_vartype n)::os,st) + ? ?| f s st = let val c = String.sub(s,0) open Char Option Int + ? ? ?in if c = #"\"" then push(OName(valOf(String.fromString (trimlr s))),st) else + ? ? ? ? if isDigit c then push(ONum(valOf(fromString s)),st) else + ? ? ? ? if c = #"#" then st else + ? ? ? ? raise ERR ("Unknown command: "^s) + ? ? ?end + ?fun loop x = case TextIO.inputLine input of + ? ?NONE => x before TextIO.closeIn(input) + ?| SOME line => loop (f (trimr line) x) +in Net.listItems (#thms (loop {stack=[],dict=Map.mkDict(Int.compare),thms=Net.empty})) end + +fun read_article s r = + ?raw_read_article + ? ?{tyop_from_ot=tyop_from_ot(), + ? ? const_from_ot=const_from_ot()} + ? ?(TextIO.openIn s) r ?end Modified: HOL/src/opentheory/selftest.sml =================================================================== --- HOL/src/opentheory/selftest.sml ? ? 2011-01-10 06:01:44 UTC (rev 8844) +++ HOL/src/opentheory/selftest.sml ? ? 2011-01-10 17:32:29 UTC (rev 8845) @@ -1,17 +1,63 @@ -open Opentheory +open Opentheory boolTheory boolLib bossLib HolKernel ?fun cmd pkg out = ("opentheory info --article -o "^out^" "^pkg) -val pkg = "bool-def-1.0" -val tmp = OS.FileSys.tmpName() -val _ = if OS.Process.isSuccess(Systeml.system_ps (cmd pkg tmp)) then let -val thms = read_article (TextIO.openIn tmp) { - ?thms=empty_thms, +val pkg = "bool-1.0" +(* +show: "Data.Bool" +input type operators: -> bool +input constants: = select +assumptions: +defined constants: ! /\ ==> ? ?! \/ ~ cond let F T +axioms: + ?|- !t. (\x. t x) = t + ?|- !P x. P x ==> P ((select) P) + ? types=typesFromList ? [("bool",fn [] => Type.bool), ? ?("->",fn ls => Type.mk_type("fun",ls))], ? consts=constsFromList ? [("=",fn ty => Term.mk_const("=",ty)), - ? ("Data.Bool.select",fn ty => Term.mk_const("@",ty))]} -val thms = thmsFromList thms + ? ("Data.Bool.select",fn ty => Term.mk_const("@",ty))] +*) +val tmp = OS.FileSys.tmpName() +val _ = if OS.Process.isSuccess(Systeml.system_ps (cmd pkg tmp)) then let +val input = TextIO.openIn tmp +val tyop_from_ot = Redblackmap.fromList String.compare [ + ?("bool",{Thy="min",Tyop="bool"}), + ?("->",{Thy="min",Tyop="fun"})] +val const_from_ot = Redblackmap.fromList String.compare [ + ?("=",{Thy="min",Name="="}), + ?("Data.Bool.select",{Thy="min",Name="@"})] +val A = INST_TYPE[alpha|->mk_vartype"A",beta|->mk_vartype"B"] +val reader = { + ?tyops=Redblackmap.mkDict String.compare, + ?consts= + ?Redblackmap.fromList String.compare [ + ? ? ?("Data.Bool.!", fn _ => {const={Thy="bool",Name="!"},def=A FORALL_DEF}), + ? ? ?("Data.Bool./\\", let + ? ? ? ?val th = prove(``$/\ = \p q. (\f. f p q) = \f:bool->bool->bool. f T T``, + ? ? ? ? ? ? ? ? ? ? ? SRW_TAC [][AND_DEF,FUN_EQ_THM] THEN EQ_TAC THEN SRW_TAC [][]) + ? ? ? ?in fn _ => {const={Thy="bool",Name="/\\"},def=th} end), + ? ? ?("Data.Bool.==>",let + ? ? ? ?val th = METIS_PROVE [] ``$==> = \p q. p /\ q <=> p`` + ? ? ? ?in fn _ => {const={Thy="min",Name="==>"},def=th} end), + ? ? ?("Data.Bool.?", let + ? ? ? ? val th = prove(``$? = \P. !q. (!x. P x ==> q) ==> q``, + ? ? ? ? ? ? ? ? ? ? ? ?SRW_TAC [][EXISTS_DEF,FUN_EQ_THM,EQ_IMP_THM] THEN + ? ? ? ? ? ? ? ? ? ? ? ?FIRST_X_ASSUM MATCH_MP_TAC THEN METIS_TAC [SELECT_AX]) + ? ? ? ?in fn _ => {const={Thy="bool",Name="?"},def=A th} end), + ? ? ?("Data.Bool.?!", fn _ => {const={Thy="bool",Name="?!"},def=A EXISTS_UNIQUE_DEF}), + ? ? ?("Data.Bool.\\/", fn _ => {const={Thy="bool",Name="\\/"},def=OR_DEF}), + ? ? ?("Data.Bool.~", fn _ => {const={Thy="bool",Name="~"},def=NOT_DEF}), + ? ? ?("Data.Bool.cond", fn _ => {const={Thy="bool",Name="COND"},def=A COND_DEF}), + ? ? ?("Data.Bool.let", fn _ => {const={Thy="bool",Name="LET"},def=A LET_DEF}), + ? ? ?("Data.Bool.F", fn _ => {const={Thy="bool",Name="F"},def=F_DEF}), + ? ? ?("Data.Bool.T", fn _ => {const={Thy="bool",Name="T"},def=T_DEF})], + ?axioms=let open List Net Thm + ? ?fun ins th = insert(concl th,th) + ? ?val n = ins (A ETA_AX) (ins (A SELECT_AX) empty) + ? ?fun f _ (_,c) = hd (index c n) + ?in f end } +val thms = raw_read_article {tyop_from_ot=tyop_from_ot, const_from_ot=const_from_ot} input reader ?(* TODO: check that thms is the same set that opentheory ? ? ? ? ?says the package should have produced *) ?in () end else () This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Gaining the trust of online customers is vital for the success of any company that requires sensitive data to be transmitted over the Web. ? Learn how to best implement a security strategy that keeps consumers' information secure and instills the confidence they need to proceed with transactions. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Hol-checkins mailing list Hol-checkins at lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hol-checkins From ramana.kumar at gmail.com Mon Jan 10 17:41:16 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 17:41:16 +0000 Subject: [opentheory-users] names of theorems Message-ID: Does OpenTheory have any notion of a theorem's name? As far as I can see we have names for constants (including type operators) and theories (i.e. packages), but not theorems. I suppose the statement of the theorem is a good identifier in many ways, especially if there is good term matching software available. Natural language names can be mnemonic though. From joe at gilith.com Mon Jan 10 18:18:55 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 10:18:55 -0800 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: Hi Ramana, > I'd love to see how you envision the purpose of opentheory and > articles and how they would interact with various proof assistants, if > you've written that down anywhere I might not have seen yet. I know > there are those two papers on your website. I recently wrote a paper on the OpenTheory standard library that contains some details on this: http://www.gilith.com/research/papers/stdlib.pdf Any comments would be gratefully received. > Suppose you're reading an article without any clashing definitions, > i.e. any constant the article wants to define is not already defined > in the reader's world. > The axioms of the article will be about those undefined constants. > When the reader comes to process the axiom command, it needs to > provide a theorem. > How is the reader supposed to have a theorem about a constant it > hasn't yet defined? I think there are a couple of important points here: 1. OpenTheory axioms are theory assumptions that mention type operators or constants defined in the theory. Assumptions that only mention undefined type operators and constants are not called axioms (even though the same "axiom" command is used to generate them), and the client theorem prover must provide theorems for these. 2. The whole of higher order logic as implemented in HOL theorem provers only depends on the 3 axioms listed in base-1.0, and each theorem prover already has local versions of these. Everything else is constructed definitionally, so the situation of needing additional axioms should never occur, which is why I initially said that axioms can be safely ignored. Does that make sense now? Cheers, Joe From joe at gilith.com Mon Jan 10 18:29:19 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 10:29:19 -0800 Subject: [opentheory-users] names of theorems In-Reply-To: References: Message-ID: Hi Ramana, There are no theorem names in OpenTheory. One design goal of OpenTheory is to minimize the use of names (which may change between theorem prover implementations), and make sure that all names can be easily renamed, which is why: 1. The interpret: tags in theory files can be used to rename theory type operators and constants. 2. The opentheory tool outputs a warning if theories export theorems with free (term) variables, and primitive inferences work modulo alpha equivalence. I lament the loss of a short mnemonic to refer to OpenTheory theorems, but I expect that each theorem prover will maintain their own mapping between OpenTheory theorem statements and local theorem names to provide this feature to users. Cheers, Joe On Mon, Jan 10, 2011 at 9:41 AM, Ramana Kumar wrote: > Does OpenTheory have any notion of a theorem's name? > As far as I can see we have names for constants (including type > operators) and theories (i.e. packages), but not theorems. > I suppose the statement of the theorem is a good identifier in many > ways, especially if there is good term matching software available. > Natural language names can be mnemonic though. > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 18:32:20 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 18:32:20 +0000 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 6:18 PM, Joe Hurd wrote: > Hi Ramana, > >> I'd love to see how you envision the purpose of opentheory and >> articles and how they would interact with various proof assistants, if >> you've written that down anywhere I might not have seen yet. I know >> there are those two papers on your website. > > I recently wrote a paper on the OpenTheory standard library that > contains some details on this: > > http://www.gilith.com/research/papers/stdlib.pdf > > Any comments would be gratefully received. > >> Suppose you're reading an article without any clashing definitions, >> i.e. any constant the article wants to define is not already defined >> in the reader's world. >> The axioms of the article will be about those undefined constants. >> When the reader comes to process the axiom command, it needs to >> provide a theorem. >> How is the reader supposed to have a theorem about a constant it >> hasn't yet defined? > > I think there are a couple of important points here: > > 1. OpenTheory axioms are theory assumptions that mention type > operators or constants defined in the theory. Assumptions that only > mention undefined type operators and constants are not called axioms > (even though the same "axiom" command is used to generate them), and > the client theorem prover must provide theorems for these. > > 2. The whole of higher order logic as implemented in HOL theorem > provers only depends on the 3 axioms listed in base-1.0, and each > theorem prover already has local versions of these. Everything else is > constructed definitionally, so the situation of needing additional > axioms should never occur, which is why I initially said that axioms > can be safely ignored. > > Does that make sense now? 1. makes sense. What may have been confusing before is that from the reader's perspective versus from the article's perspective "defined" and "undefined" are somewhat opposite. For 2... I think we may just be interpreting our words differently. By "axioms" I meant the list of theorems so labelled by opentheory info --summary, and these cannot be ignored by a reader - they must be provided by the reader for the article to succeed. > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Mon Jan 10 18:53:27 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 10:53:27 -0800 Subject: [opentheory-users] quoted strings In-Reply-To: References: Message-ID: Hi Ramana, I've tried to be clearer in the article specification what the format is for strings: http://www.gilith.com/research/opentheory/article.html#nameCommand Could you take a look and see if that answers your questions? Cheers, Joe On Mon, Jan 10, 2011 at 7:21 AM, Ramana Kumar wrote: > It appears that the quoted string command allows (requires) special > characters to be escaped. > For example, bool.art from bool-1.0 contains the following line, literally: > > "Data.Bool./\\" > > Is that name 'Data.Bool./\' or 'Data.Bool./\\'? > > The article format specification is at best unclear about this. > Reading the specification literally, it looks like you get a command > "s" (the quotation marks are literal characters and between them is a > variable) and interpret it as Name s, not Name (parse_as_string s). Of > course it does say that the variable stands for a string, and maybe > that's supposed to be the clue that it might contain character > escapes... > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Mon Jan 10 18:57:12 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 10:57:12 -0800 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: Hi Ramana, I think we are converging here. I agree that the terminology of defined and input is potentially confusing, but it is at least consistent from the point of view of the theory. > For 2... I think we may just be interpreting our words differently. By > "axioms" I meant the list of theorems so labelled by opentheory info > --summary, and these cannot be ignored by a reader - they must be > provided by the reader for the article to succeed. I've just checked, and I believe opentheory --summary is correctly classifying assumptions and axioms according to the definition I gave you. Please let me know if you find an example where it deviates - I would treat that as a bug. Cheers, Joe From joe at gilith.com Mon Jan 10 18:58:02 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 10:58:02 -0800 Subject: [opentheory-users] Fwd: [Hol-checkins] SF.net SVN: hol:[8845] HOL/src/opentheory In-Reply-To: References: Message-ID: Hi Ramana, This looks excellent - I will give it a go as soon as I get some time. Cheers, Joe On Mon, Jan 10, 2011 at 9:35 AM, Ramana Kumar wrote: > My new implementation of the article reader for HOL4 (svn r8845) now > successfully reads bool-1.0 (although I didn't check all the theorems > were there - it looks reasonable, though). > > In the HOL repo, src/opentheory/selftest.sml is an example of how to > use the reader, and src/opentheory/Opentheory.sig has some descriptive > comments. > > > ---------- Forwarded message ---------- > From: ? > Date: Mon, Jan 10, 2011 at 5:32 PM > Subject: [Hol-checkins] SF.net SVN: hol:[8845] HOL/src/opentheory > To: hol-checkins at lists.sf.net > > > Revision: 8845 > ? ? ? ? ?http://hol.svn.sourceforge.net/hol/?rev=8845&view=rev > Author: ? xrchz > Date: ? ? 2011-01-10 17:32:29 +0000 (Mon, 10 Jan 2011) > > Log Message: > ----------- > Complete rewrite of Opentheory reader > > It now successfully reads the package bool-1.0 in the gilith repository, > and that is the selftest (only runs if you have opentheory installed). > > The selftest file is also an example of the work you might need to do to > read an opentheory article that defines constants that are already > defined in HOL. > > When the article is only going to define new things, the work would > likely be less, although some helper functions (TODO) in the Opentheory > module would make it easier. > > Modified Paths: > -------------- > ? ?HOL/src/opentheory/Opentheory.sig > ? ?HOL/src/opentheory/Opentheory.sml > ? ?HOL/src/opentheory/selftest.sml > > Modified: HOL/src/opentheory/Opentheory.sig > =================================================================== > --- HOL/src/opentheory/Opentheory.sig ? 2011-01-10 06:01:44 UTC (rev 8844) > +++ HOL/src/opentheory/Opentheory.sig ? 2011-01-10 17:32:29 UTC (rev 8845) > @@ -1,12 +1,51 @@ > ?signature Opentheory = sig > - ?type thms ? = Thm.thm Net.net > - ?type types ?= (string, Type.hol_type list -> Type.hol_type) Redblackmap.dict > - ?type consts = (string, Type.hol_type -> Term.term) Redblackmap.dict > - ?val empty_thms ? ? : thms > - ?val empty_types ? ?: types > - ?val empty_consts ? : consts > - ?val thmsFromList ? : Thm.thm list -> thms > - ?val typesFromList ?: (string * (Type.hol_type list -> > Type.hol_type)) list -> types > - ?val constsFromList : (string * (Type.hol_type -> Term.term)) list -> consts > - ?val read_article ? : TextIO.instream -> > {thms:thms,types:types,consts:consts} -> Thm.thm list > +type term = Term.term type hol_type = Type.hol_type type thm = Thm.thm > +type ('a,'b) dict = ('a,'b) Redblackmap.dict > + > +(* maps between OpenTheory names and HOL4 names: *) > +type thy_tyop ?= {Thy:string,Tyop:string} > +type thy_const = {Thy:string,Name:string} > +type 'a to_ot ?= ('a,string) dict > +type 'a from_ot= (string,'a) dict > +val tyop_to_ot ? : unit -> thy_tyop to_ot > +val tyop_from_ot : unit -> thy_tyop from_ot > +val const_to_ot ?: unit -> thy_const to_ot > +val const_from_ot: unit -> thy_const from_ot > + > +(* record of data an article reader must provide: *) > +type reader = { > + ?tyops ?: (string, {axiom:thm, args:hol_type list, rep:string, abs:string} -> > + ? ? ? ? ? ? ? ? ? ?{rep_abs:thm, abs_rep:thm, rep:term, abs:term, > tyop:thy_tyop}) > + ? ? ? ? ? dict, > + ?consts : (string, term -> {const:thy_const, def:thm}) dict, > + ?axioms : thm Net.net -> (term list * term) -> thm} > + > +(* > +tyops are type operators the article will define, indexed by their OpenTheory > +names. Each name is mapped to a function that does something equivalent to > +defining the new type. Each function is provided the type axiom, a list of > +arguments (type variables) for the type operator in the desired order, and the > +OpenTheory names of the rep and abs constants. It must return the new type > +operator, the rep and abs constants, and the type bijection theorems. > +If axiom = |- P t then these are: > + ?abs_rep = |- (!a. abs (rep a) = a) > + ?rep_abs = |- (!r. P r = (rep(abs r) = r)) > + > +consts are constants the article will define, indexed by their OpenTheory > +names. Each name is mapped to a function that does something equivalent to > +defining the new constant. Each function is provided the right hand side rhs of > +the definition and must return the name of the constant and an equational > +theorem |- const = rhs. > + > +axioms are theorems that the article depends on about possibly both input > +and output tyops and constants. They are represented by a function that takes > +the collection of theorems the article has already proved, represented by a > +conclusion-indexed net, and a pair (h,c) representing the desired axiom, and > +must return a theorem h |- c. > +*) > + > +val raw_read_article : {tyop_from_ot:thy_tyop from_ot, > + ? ? ? ? ? ? ? ? ? ? ? ?const_from_ot:thy_const from_ot} > + ? ? ? ? ? -> TextIO.instream -> reader -> thm list > +val read_article ? ? : string -> reader -> thm list > ?end > > Modified: HOL/src/opentheory/Opentheory.sml > =================================================================== > --- HOL/src/opentheory/Opentheory.sml ? 2011-01-10 06:01:44 UTC (rev 8844) > +++ HOL/src/opentheory/Opentheory.sml ? 2011-01-10 17:32:29 UTC (rev 8845) > @@ -1,221 +1,162 @@ > ?structure Opentheory :> Opentheory = struct > > -val ERR = Feedback.mk_HOL_ERR "Opentheory" > +open boolSyntax HolKernel Parse > > +local open Drule Conv in > + ?fun DEDUCT_ANTISYM th1 th2 = > + ? ?IMP_ANTISYM_RULE > + ? ? ?(DISCH (concl th2) th1) > + ? ? ?(DISCH (concl th1) th2) > + ?fun absThm (v,tu) = let > + ? ?val (t,u) = dest_eq(concl tu) > + ? ?val vt = mk_abs(v,t) > + ? ?val vu = mk_abs(v,u) > + ? ?val vtvu = mk_eq(vt,vu) > + ? ?val x = FUN_EQ_CONV vtvu > + ? ?val x = CONV_RULE (RAND_CONV (QUANT_CONV (LAND_CONV BETA_CONV))) x > + ? ?val x = CONV_RULE (RAND_CONV (QUANT_CONV (RAND_CONV BETA_CONV))) x > + ?in EQ_MP (SYM x) (GEN v tu) end > +end > + > +val ERR = mk_HOL_ERR "Opentheory" > + > ?structure Map = Redblackmap > -type thms ? = Thm.thm Net.net > -type types ?= (string, Type.hol_type list -> Type.hol_type) Map.dict > -type consts = (string, Type.hol_type -> Term.term) Map.dict > +type ('a,'b) dict = ('a,'b) Map.dict > > -val empty_thms ? ? = Net.empty > -val empty_types ? ?= Map.mkDict String.compare > -val empty_consts ? = Map.mkDict String.compare > -val thmsFromList ? = List.foldl (fn (th,n) => Net.insert(Thm.concl > th,th) n) empty_thms > -val typesFromList ?= Map.fromList String.compare > -val constsFromList = Map.fromList String.compare > +type thy_tyop ?= {Thy:string,Tyop:string} > +type thy_const = {Thy:string,Name:string} > +type 'a to_ot ?= ('a,string) dict > +type 'a from_ot= (string,'a) dict > +fun lex_cmp c (f1,f2) (x1,x2) = > + ?case c(f1 x1,f1 x2) of EQUAL => c(f2 x1,f2 x2) | z => z > +val thy_tyop_cmp ?= lex_cmp String.compare (#Tyop,#Thy) > +val thy_const_cmp = lex_cmp String.compare (#Name,#Thy) > +val the_tyop_to_ot ? = ref (Map.mkDict thy_tyop_cmp) > +val the_tyop_from_ot = ref (Map.mkDict String.compare) > +val the_const_to_ot ?= ref (Map.mkDict thy_const_cmp) > +val the_const_from_ot= ref (Map.mkDict String.compare) > +fun tyop_to_ot() ? = !the_tyop_to_ot > +fun tyop_from_ot() = !the_tyop_from_ot > +fun const_to_ot() ?= !the_const_to_ot > +fun const_from_ot()= !the_const_from_ot > > ?datatype object > ?= ONum of int > ?| OName of string > ?| OList of object list > -| OTypeOp of string > -| OType of Type.hol_type > -| OConst of string > -| OVar of Term.term > -| OTerm of Term.term > -| OThm of Thm.thm > +| OTypeOp of thy_tyop > +| OType of hol_type > +| OConst of thy_const > +| OVar of term > +| OTerm of term > +| OThm of thm > > -datatype command > -= Num of int > -| Name of string > -| AbsTerm > -| AbsThm > -| AppTerm > -| AppThm > -| Assume > -| Axiom > -| BetaConv > -| Cons > -| Const > -| ConstTerm > -| DeductAntisym > -| Def > -| DefineConst > -| DefineTypeOp > -| EqMp > -| Nil > -| OpType > -| Pop > -| Ref > -| Refl > -| Remove > -| Subst > -| Thm > -| TypeOp > -| Var > -| VarTerm > -| VarType > +type reader = > + ? {tyops ?: (string, {axiom:thm, args:hol_type list, rep:string, > abs:string} -> > + ? ? ? ? ? ? ? ? ? ? ?{rep_abs:thm, abs_rep:thm, rep:term, abs:term, > tyop:thy_tyop}) > + ? ? ? ? ? ? dict, > + ? ?consts : (string, term -> {const:thy_const, def:thm}) dict, > + ? ?axioms : thm Net.net -> (term list * term) -> thm} > > -fun st_ (st,{stack,dict,thms}) = {stack=st,dict=dict,thms=thms} > -fun push (ob,state) = st_ (ob::(#stack state),state) > - > -fun find_thm thms (h,c) = let > - ?val candidates = Net.index c thms > - ?fun equal thm = let > - ? ?val c' = Thm.concl thm > - ? ?val thm' = Drule.PART_MATCH Lib.I thm (#2(boolSyntax.strip_forall c)) > - ?in Lib.set_eq h (Thm.hyp thm') end handle Feedback.HOL_ERR _ => false > - ?val SOME th = List.find equal candidates > -in th end > - > -fun find_const consts (n,t) = Map.find(consts,n) t > -handle Map.NotFound => Term.mk_const(n,t) > -handle Feedback.HOL_ERR _ => raise ERR "find_const" ("need "^n^" of > type "^(Parse.type_to_string t)) > - > -local open Thm Drule in > -fun DEDUCT_ANTISYM th1 th2 = > - ?IMP_ANTISYM_RULE > - ? ?(DISCH (concl th1) th2) > - ? ?(DISCH (concl th2) th1) > +fun st_(st,{stack,dict,thms}) = {stack=st,dict=dict,thms=thms} > +fun push (ob,st) = st_(ob::(#stack st),st) > +local open Substring in > + ?val trimlr = fn s => string(trimr 1 (triml 1 (full s))) > + ?val trimr ?= fn s => string(trimr 1 (full s)) > ?end > > -val unOTermls = List.map (fn OTerm t => t) > -val unOTypels = List.map (fn OType t => t) > -val unONamels = List.map (fn OName n => n) > - > -fun find_type types (t,ls) = let > - ?val ls = unOTypels ls > -in > - ?(Map.find(types,t)) ls > - ?handle Map.NotFound => let > - ? ?val s = Parse.type_to_string(Type.mk_type(t,ls)) > - ? ?handle Feedback.HOL_ERR _ => > - ? ?(* PolyML.makestring (t, (Map.listItems types)) *) > - ? ?("TyOp = "^t^", Args = "^(String.concatWith ", " (List.map > Parse.type_to_string ls))) > - ?in raise ERR "find_type" ("need "^s) end > -end > - > -exception Comment > - > -fun > - ?parse_line "absTerm" ? ? ? = AbsTerm > -| parse_line "absThm" ? ? ? ?= AbsThm > -| parse_line "appTerm" ? ? ? = AppTerm > -| parse_line "appThm" ? ? ? ?= AppThm > -| parse_line "assume" ? ? ? ?= Assume > -| parse_line "axiom" ? ? ? ? = Axiom > -| parse_line "betaConv" ? ? ?= BetaConv > -| parse_line "cons" ? ? ? ? ?= Cons > -| parse_line "const" ? ? ? ? = Const > -| parse_line "constTerm" ? ? = ConstTerm > -| parse_line "deductAntisym" = DeductAntisym > -| parse_line "def" ? ? ? ? ? = Def > -| parse_line "defineConst" ? = DefineConst > -| parse_line "defineTypeOp" ?= DefineTypeOp > -| parse_line "eqMp" ? ? ? ? ?= EqMp > -| parse_line "nil" ? ? ? ? ? = Nil > -| parse_line "opType" ? ? ? ?= OpType > -| parse_line "pop" ? ? ? ? ? = Pop > -| parse_line "ref" ? ? ? ? ? = Ref > -| parse_line "refl" ? ? ? ? ?= Refl > -| parse_line "remove" ? ? ? ?= Remove > -| parse_line "subst" ? ? ? ? = Subst > -| parse_line "thm" ? ? ? ? ? = Thm > -| parse_line "typeOp" ? ? ? ?= TypeOp > -| parse_line "var" ? ? ? ? ? = Var > -| parse_line "varTerm" ? ? ? = VarTerm > -| parse_line "varType" ? ? ? = VarType > -| parse_line s = let > - ? ?val c = String.sub(s,0) > - ?in if c = #"\"" then Name (String.substring(s,1,String.size s -2)) else > - ? ? if Char.isDigit c then Num (Option.valOf (Int.fromString s)) > - ? ? else raise Comment > - ?end > - > -fun read_article file {types,consts,thms} = let > - ?val find_asm ? = find_thm thms > - ?val find_const = find_const consts > - ?val find_type ?= find_type types > - ?fun f (Num i) ?st = push(ONum i,st) > - ? ?| f (Name s) st = push(OName s,st) > - ? ?| f AbsTerm ?(st as {stack=OTerm b::OVar v::os,...}) ?= > st_(OTerm(Term.mk_abs(v,b))::os,st) > - ? ?| f AppTerm ?(st as {stack=OTerm x::OTerm f::os,...}) = > st_(OTerm(Term.mk_comb(f,x))::os,st) > - ? ?| f AppThm ? (st as {stack=OThm xy::OThm fg::os,...}) = let > - ? ? ? ?val (f,g) = boolSyntax.dest_eq(Thm.concl fg) > - ? ? ? ?val (x,y) = boolSyntax.dest_eq(Thm.concl xy) > - ? ? ? ?val fxgx ?= Thm.AP_THM fg x > - ? ? ? ?val gxgy ?= Thm.AP_TERM g xy > - ? ? ?in st_(OThm(Thm.TRANS fxgx gxgy)::os,st) end > - ? ?| f Assume ? ? ? ?(st as {stack=OTerm t::os,...}) ? ? ? ? ? = > st_(OThm(Thm.ASSUME t)::os,st) > - ? ?| f Axiom ? ? ? ? (st as {stack=OTerm t::OList ts::os,...}) = > st_(OThm(find_asm(unOTermls ts,t))::os,st) > - ? ?| f BetaConv ? ? ?(st as {stack=OTerm t::os,...}) ? ? ? ? ? = > st_(OThm(Thm.BETA_CONV t)::os,st) > - ? ?| f Cons ? ? ? ? ?(st as {stack=OList t::h::os,...}) ? ? ? ?= > st_(OList(h::t)::os,st) > - ? ?| f Const ? ? ? ? (st as {stack=OName n::os,...}) ? ? ? ? ? = > st_(OConst n::os,st) > - ? ?| f ConstTerm ? ? (st as {stack=OType t::OConst c::os,...}) = > st_(OTerm(find_const (c,t))::os,st) > - ? ?| f DeductAntisym (st as {stack=OThm t1::OThm t2::os,...}) ?= > st_(OThm(DEDUCT_ANTISYM t1 t2)::os,st) > - ? ?| f Def ? ? ? ? ? {stack=ONum k::x::os,dict,thms} ? ? ? ? ? = > {stack=x::os,dict=Map.insert(dict,k,x),thms=thms} > - ? ?| f DefineConst ? (st as {stack=OTerm t::OName n::os,...}) ?= let > - ? ? ? ?val t = boolSyntax.mk_eq(Term.mk_var(n,Term.type_of t),t) > - ? ? ? ?val def = Definition.new_definition(n,t) > - ? ? ? ?handle Feedback.HOL_ERR _ => raise ERR "read_article" > ("DefineConst "^n^" by "^Parse.term_to_string t^" failed") > - ? ? ?in st_(OThm def::OConst n::os,st) end > - ? ?| f DefineTypeOp ?(st as {stack=OThm th::OList ls::OName > rep::OName abs::OName n::os,...}) = let > - ? ? ? ?val ls = unONamels ls > - ? ? ? ?val sorted = Lib.sort (Lib.curry (Lib.equal LESS o String.compare)) ls > - ? ? ? ?val s = let fun f (a,a',s) = if a = a' then s else let > - ? ? ? ? ? ? ? ? ? ? ?val a = Type.mk_vartype a > - ? ? ? ? ? ? ? ? ? ? ?val a' = Type.mk_vartype a' > - ? ? ? ? ? ? ? ? ? ? ?val op |-> = Lib.|-> infix |-> > - ? ? ? ? ? ? ? ? ? ?in (a |-> a')::(a' |-> a)::s end > - ? ? ? ? ? ? ? ?in ListPair.foldlEq f [] (ls,sorted) end > - ? ? ? ?val th = Thm.INST_TYPE s th > - ? ? ? ?val Pt = Thm.concl th > - ? ? ? ?val (P,t) = Term.dest_comb(Pt) > - ? ? ? ?val th = Thm.EXISTS(boolSyntax.mk_exists(t,Pt),t) th > - ? ? ? ?val tyax = Definition.new_type_definition(n,th) > - ? ? ? ?val th = Drule.define_new_type_bijections > {name=n^"_repfns",ABS=abs,REP=rep,tyax=tyax} > - ? ? ? ?val th1 = Drule.SPEC_ALL (Thm.CONJUNCT1 th) > - ? ? ? ?val th2 = Drule.SPEC_ALL (Thm.CONJUNCT2 th) > - ? ? ?in st_(OThm th2::OThm ?th1::OConst rep::OConst abs::OTypeOp n::os,st) end > - ? ?| f EqMp ? (st as {stack=OThm fg::OThm f::os,...}) ? ? = > st_(OThm(Thm.EQ_MP fg f)::os,st) > - ? ?| f Nil ? ?st ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?= push(OList [],st) > - ? ?| f OpType (st as {stack=OList ls::OTypeOp t::os,...}) = > st_(OType(find_type(t,ls))::os,st) > - ? ?| f Pop ? ?(st as {stack=x::os,...}) ? ? ? ? ? ? ? ? ? = st_(os,st) > - ? ?| f Ref ? ?(st as {stack=ONum k::os,dict,...}) ? ? ? ? = > st_(Map.find(dict,k)::os,st) > - ? ?| f Refl ? (st as {stack=OTerm t::os,...}) ? ? ? ? ? ? = > st_(OThm(Thm.REFL t)::os,st) > - ? ?| f Remove {stack=ONum k::os,dict,thms} ? ? ? ? ? ? ? ?= let > +fun raw_read_article {tyop_from_ot,const_from_ot} input > {tyops,consts,axioms} = let > + ?val ERR = ERR "read_article" > + ?fun unOTermls c = List.map (fn OTerm t => t | _ => raise ERR (c^" > failed to pop a list of terms")) > + ?fun unOTypels c = List.map (fn OType t => t | _ => raise ERR (c^" > failed to pop a list of types")) > + ?fun ot_to_const c s = Map.find(const_from_ot,s) > + ?handle Map.NotFound => raise ERR (c^": no map from "^s^" to a constant") > + ?fun ot_to_tyop ?c s = Map.find(tyop_from_ot ,s) > + ?handle Map.NotFound => raise ERR (c^": no map from "^s^" to a type operator") > + ?fun f "absTerm"(st as {stack=OTerm b::OVar v::os,...}) = > st_(OTerm(mk_abs(v,b))::os,st) > + ? ?| f "absThm" (st as {stack=OThm th::OVar v::os,...}) = > (st_(OThm(absThm(v,th))::os,st) > + ? ? ?handle HOL_ERR e => raise ERR ("absThm: failed with "^format_ERR e)) > + ? ?| f "appTerm"(st as {stack=OTerm x::OTerm f::os,...})= > st_(OTerm(mk_comb(f,x))::os,st) > + ? ?| f "appThm" (st as {stack=OThm xy::OThm fg::os,...})= let > + ? ? ? ?val (f,g) = dest_eq(concl fg) > + ? ? ? ?val (x,y) = dest_eq(concl xy) > + ? ? ? ?val fxgx ?= AP_THM fg x > + ? ? ? ?val gxgy ?= AP_TERM g xy > + ? ? ?in st_(OThm(TRANS fxgx gxgy)::os,st) end > + ? ?| f "assume" ? ? ? (st as {stack=OTerm t::os,...}) ? ? ? ? ?= > st_(OThm(ASSUME t)::os,st) > + ? ?| f "axiom" ? ? ? ?(st as {stack=OTerm t::OList ts::os,thms,...}) > = st_(OThm(axioms thms (unOTermls "axiom" ts,t))::os,st) > + ? ?| f "betaConv" ? ? (st as {stack=OTerm t::os,...}) ? ? ? ? ?= > st_(OThm(BETA_CONV t)::os,st) > + ? ?| f "cons" ? ? ? ? (st as {stack=OList t::h::os,...}) ? ? ? = > st_(OList(h::t)::os,st) > + ? ?| f "const" ? ? ? ?(st as {stack=OName n::os,...}) ? ? ? ? ?= > st_(OConst (ot_to_const "const" n)::os,st) > + ? ?| f "constTerm" ? ?(st as {stack=OType Ty::OConst {Thy,Name}::os,...}) > + ? ? ? ? ? ? ? ? ? ? = st_(OTerm(mk_thy_const > {Ty=Ty,Thy=Thy,Name=Name})::os,st) > + ? ?| f "deductAntisym"(st as {stack=OThm t1::OThm t2::os,...}) = > st_(OThm(DEDUCT_ANTISYM t1 t2)::os,st) > + ? ?| f "def" ? ? ? ? {stack=ONum k::x::os,dict,thms} ? ? ? ? ? = > {stack=x::os,dict=Map.insert(dict,k,x),thms=thms} > + ? ?| f "defineConst" (st as {stack=OTerm t::OName n::os,...}) ?= let > + ? ? ? ?val {const,def} = Map.find(consts,n) t > + ? ? ? ?handle Map.NotFound => raise ERR ("defineConst: no map from > "^n^" to a definition function") > + ? ? ?in st_(OThm def::OConst const::os,st) end > + ? ?| f "defineTypeOp" ?(st as {stack=OThm th::OList ls::OName > rep::OName abs::OName n::os,...}) = let > + ? ? ? ?val ls = List.map (fn OName s => mk_vartype s | _ => raise > ERR "defineTypeOp failed to pop a list of names") ls > + ? ? ? ?val {abs,rep,abs_rep,rep_abs,tyop} = Map.find(tyops,n) > {axiom=th,args=ls,rep=rep,abs=abs} > + ? ? ? ?val {Thy,Name,...} = dest_thy_const rep val rep = {Thy=Thy,Name=Name} > + ? ? ? ?val {Thy,Name,...} = dest_thy_const abs val abs = {Thy=Thy,Name=Name} > + ? ? ?in st_(OThm rep_abs::OThm abs_rep::OConst rep::OConst > abs::OTypeOp tyop::os,st) end > + ? ?| f "eqMp" ? (st as {stack=OThm f::OThm fg::os,...}) ? ? = > (st_(OThm(EQ_MP fg f)::os,st) > + ? ? ?handle HOL_ERR _ => raise ERR ("EqMp failed on "^thm_to_string > fg^" and "^thm_to_string f)) > + ? ?| f "nil" ? ?st ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?= > push(OList [],st) > + ? ?| f "opType" (st as {stack=OList ls::OTypeOp {Thy,Tyop}::os,...}) > + ? ? ? ? ? ? ? = > st_(OType(mk_thy_type{Thy=Thy,Tyop=Tyop,Args=unOTypels "opType" > ls})::os,st) > + ? ?| f "pop" ? ?(st as {stack=x::os,...}) ? ? ? ? ? ? ? ? ? = st_(os,st) > + ? ?| f "ref" ? ?(st as {stack=ONum k::os,dict,...}) ? ? ? ? = > st_(Map.find(dict,k)::os,st) > + ? ?| f "refl" ? (st as {stack=OTerm t::os,...}) ? ? ? ? ? ? = > st_(OThm(REFL t)::os,st) > + ? ?| f "remove" {stack=ONum k::os,dict,thms} ? ? ? ? ? ? ? ?= let > ? ? ? ? val (dict,x) = Map.remove(dict,k) > ? ? ? in {stack=x::os,dict=dict,thms=thms} end > - ? ?| f Subst ?(st as {stack=OThm th::OList[OList tys,OList > tms]::os,...}) = let > - ? ? ? ?val tys = List.map (fn OList [OName a, OType t] => > {redex=Type.mk_vartype a, residue=t}) tys > - ? ? ? ?val tms = List.map (fn OList [OVar v, OTerm t] => {redex=v, > residue=t}) tms > - ? ? ? ?val th = Thm.INST_TYPE tys th > - ? ? ? ?val th = Thm.INST tms th > + ? ?| f "subst" ?(st as {stack=OThm th::OList[OList tys,OList > tms]::os,...}) = let > + ? ? ? ?val tys = List.map (fn OList [OName a, OType t] => > {redex=mk_vartype a, residue=t} > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? | _ => raise ERR "subst failed to pop a > list of [name,type] pairs") tys > + ? ? ? ?val tms = List.map (fn OList [OVar v, OTerm t] => {redex=v, residue=t} > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? | _ => raise ERR "subst failed to pop a > list of [var,term] pairs") tms > + ? ? ? ?val th = INST_TYPE tys th > + ? ? ? ?val th = INST tms th > ? ? ? in st_(OThm th::os,st) end > - ? ?| f Thm ? ?{stack=OTerm c::OList ls::OThm th::os,dict,thms} = let > - ? ? ? ?val th = Thm.EQ_MP (Thm.ALPHA (Thm.concl th) c) th > + ? ?| f "thm" ? ?{stack=OTerm c::OList ls::OThm th::os,dict,thms} = let > + ? ? ? ?val th = EQ_MP (ALPHA (concl th) c) th > + ? ? ? ?handle HOL_ERR _ => raise ERR "thm: desired conclusion not > alpha-equivalent to theorem's conclusion" > ? ? ? ? fun ft (OTerm h, th) = let > - ? ? ? ? ?val c = Thm.concl th > - ? ? ? ? ?val th = Thm.DISCH h th > - ? ? ? ? ?val c' = Thm.concl th > + ? ? ? ? ?val c = concl th > + ? ? ? ? ?val th = DISCH h th > + ? ? ? ? ?val c' = concl th > ? ? ? ? in > - ? ? ? ? ?if Term.aconv c c' then > + ? ? ? ? ?if aconv c c' then > ? ? ? ? ? ? Drule.ADD_ASSUM h th > ? ? ? ? ? else let > ? ? ? ? ? ? val (h',_) = boolSyntax.dest_imp c' > - ? ? ? ? ? ?val h'h = Thm.ALPHA h' h > + ? ? ? ? ? ?val h'h = ALPHA h' h > ? ? ? ? ? ? val th = Drule.SUBS_OCCS [([1],h'h)] th > ? ? ? ? ? in Drule.UNDISCH th end > - ? ? ? ?end > + ? ? ? ?end | ft _ = raise ERR "thm failed to pop a list of terms" > ? ? ? ? val th = List.foldl ft th ls > - ? ? ?in {stack=os,dict=dict,thms=th::thms} end > - ? ?| f TypeOp ?(st as {stack=OName n::os,...}) ? ? ? ? ?= > st_(OTypeOp n::os,st) > - ? ?| f Var ? ? (st as {stack=OType t::OName n::os,...}) = > st_(OVar(Term.mk_var(n,t))::os,st) > - ? ?| f VarTerm (st as {stack=OVar t::os,...}) ? ? ? ? ? = st_(OTerm t::os,st) > - ? ?| f VarType (st as {stack=OName n::os,...}) ? ? ? ? ?= > st_(OType(Type.mk_vartype n)::os,st) > - ?fun stripnl s = let open Substring in string(trimr 1 (full s)) end > - ?fun loop x = case TextIO.inputLine file of > - ? ?NONE => x before TextIO.closeIn(file) > - ?| SOME line => loop (f (parse_line (stripnl line)) x handle Comment => x) > -in #thms (loop {stack=[],dict=Map.mkDict(Int.compare),thms=[]}) end > + ? ? ?in {stack=os,dict=dict,thms=Net.insert(concl th,th)thms} end > + ? ?| f "typeOp" ?(st as {stack=OName n::os,...}) ? ? ? ? ?= > st_(OTypeOp (ot_to_tyop "typeOp" n)::os,st) > + ? ?| f "var" ? ? (st as {stack=OType t::OName n::os,...}) = > st_(OVar(mk_var(n,t))::os,st) > + ? ?| f "varTerm" (st as {stack=OVar t::os,...}) ? ? ? ? ? = > st_(OTerm t::os,st) > + ? ?| f "varType" (st as {stack=OName n::os,...}) ? ? ? ? ?= > st_(OType(mk_vartype n)::os,st) > + ? ?| f s st = let val c = String.sub(s,0) open Char Option Int > + ? ? ?in if c = #"\"" then push(OName(valOf(String.fromString (trimlr > s))),st) else > + ? ? ? ? if isDigit c then push(ONum(valOf(fromString s)),st) else > + ? ? ? ? if c = #"#" then st else > + ? ? ? ? raise ERR ("Unknown command: "^s) > + ? ? ?end > + ?fun loop x = case TextIO.inputLine input of > + ? ?NONE => x before TextIO.closeIn(input) > + ?| SOME line => loop (f (trimr line) x) > +in Net.listItems (#thms (loop > {stack=[],dict=Map.mkDict(Int.compare),thms=Net.empty})) end > + > +fun read_article s r = > + ?raw_read_article > + ? ?{tyop_from_ot=tyop_from_ot(), > + ? ? const_from_ot=const_from_ot()} > + ? ?(TextIO.openIn s) r > ?end > > Modified: HOL/src/opentheory/selftest.sml > =================================================================== > --- HOL/src/opentheory/selftest.sml ? ? 2011-01-10 06:01:44 UTC (rev 8844) > +++ HOL/src/opentheory/selftest.sml ? ? 2011-01-10 17:32:29 UTC (rev 8845) > @@ -1,17 +1,63 @@ > -open Opentheory > +open Opentheory boolTheory boolLib bossLib HolKernel > ?fun cmd pkg out = ("opentheory info --article -o "^out^" "^pkg) > -val pkg = "bool-def-1.0" > -val tmp = OS.FileSys.tmpName() > -val _ = if OS.Process.isSuccess(Systeml.system_ps (cmd pkg tmp)) then let > -val thms = read_article (TextIO.openIn tmp) { > - ?thms=empty_thms, > +val pkg = "bool-1.0" > +(* > +show: "Data.Bool" > +input type operators: -> bool > +input constants: = select > +assumptions: > +defined constants: ! /\ ==> ? ?! \/ ~ cond let F T > +axioms: > + ?|- !t. (\x. t x) = t > + ?|- !P x. P x ==> P ((select) P) > + > ? types=typesFromList > ? [("bool",fn [] => Type.bool), > ? ?("->",fn ls => Type.mk_type("fun",ls))], > ? consts=constsFromList > ? [("=",fn ty => Term.mk_const("=",ty)), > - ? ("Data.Bool.select",fn ty => Term.mk_const("@",ty))]} > -val thms = thmsFromList thms > + ? ("Data.Bool.select",fn ty => Term.mk_const("@",ty))] > +*) > +val tmp = OS.FileSys.tmpName() > +val _ = if OS.Process.isSuccess(Systeml.system_ps (cmd pkg tmp)) then let > +val input = TextIO.openIn tmp > +val tyop_from_ot = Redblackmap.fromList String.compare [ > + ?("bool",{Thy="min",Tyop="bool"}), > + ?("->",{Thy="min",Tyop="fun"})] > +val const_from_ot = Redblackmap.fromList String.compare [ > + ?("=",{Thy="min",Name="="}), > + ?("Data.Bool.select",{Thy="min",Name="@"})] > +val A = INST_TYPE[alpha|->mk_vartype"A",beta|->mk_vartype"B"] > +val reader = { > + ?tyops=Redblackmap.mkDict String.compare, > + ?consts= > + ?Redblackmap.fromList String.compare [ > + ? ? ?("Data.Bool.!", fn _ => {const={Thy="bool",Name="!"},def=A FORALL_DEF}), > + ? ? ?("Data.Bool./\\", let > + ? ? ? ?val th = prove(``$/\ = \p q. (\f. f p q) = > \f:bool->bool->bool. f T T``, > + ? ? ? ? ? ? ? ? ? ? ? SRW_TAC [][AND_DEF,FUN_EQ_THM] THEN EQ_TAC > THEN SRW_TAC [][]) > + ? ? ? ?in fn _ => {const={Thy="bool",Name="/\\"},def=th} end), > + ? ? ?("Data.Bool.==>",let > + ? ? ? ?val th = METIS_PROVE [] ``$==> = \p q. p /\ q <=> p`` > + ? ? ? ?in fn _ => {const={Thy="min",Name="==>"},def=th} end), > + ? ? ?("Data.Bool.?", let > + ? ? ? ? val th = prove(``$? = \P. !q. (!x. P x ==> q) ==> q``, > + ? ? ? ? ? ? ? ? ? ? ? ?SRW_TAC [][EXISTS_DEF,FUN_EQ_THM,EQ_IMP_THM] THEN > + ? ? ? ? ? ? ? ? ? ? ? ?FIRST_X_ASSUM MATCH_MP_TAC THEN METIS_TAC [SELECT_AX]) > + ? ? ? ?in fn _ => {const={Thy="bool",Name="?"},def=A th} end), > + ? ? ?("Data.Bool.?!", fn _ => {const={Thy="bool",Name="?!"},def=A > EXISTS_UNIQUE_DEF}), > + ? ? ?("Data.Bool.\\/", fn _ => {const={Thy="bool",Name="\\/"},def=OR_DEF}), > + ? ? ?("Data.Bool.~", fn _ => {const={Thy="bool",Name="~"},def=NOT_DEF}), > + ? ? ?("Data.Bool.cond", fn _ => > {const={Thy="bool",Name="COND"},def=A COND_DEF}), > + ? ? ?("Data.Bool.let", fn _ => {const={Thy="bool",Name="LET"},def=A LET_DEF}), > + ? ? ?("Data.Bool.F", fn _ => {const={Thy="bool",Name="F"},def=F_DEF}), > + ? ? ?("Data.Bool.T", fn _ => {const={Thy="bool",Name="T"},def=T_DEF})], > + ?axioms=let open List Net Thm > + ? ?fun ins th = insert(concl th,th) > + ? ?val n = ins (A ETA_AX) (ins (A SELECT_AX) empty) > + ? ?fun f _ (_,c) = hd (index c n) > + ?in f end } > +val thms = raw_read_article {tyop_from_ot=tyop_from_ot, > const_from_ot=const_from_ot} input reader > ?(* TODO: check that thms is the same set that opentheory > ? ? ? ? ?says the package should have produced *) > ?in () end else () > > > This was sent by the SourceForge.net collaborative development > platform, the world's largest Open Source development site. > > ------------------------------------------------------------------------------ > Gaining the trust of online customers is vital for the success of any company > that requires sensitive data to be transmitted over the Web. ? Learn how to > best implement a security strategy that keeps consumers' information secure > and instills the confidence they need to proceed with transactions. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > Hol-checkins mailing list > Hol-checkins at lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/hol-checkins > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 19:12:17 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 19:12:17 +0000 Subject: [opentheory-users] quoted strings In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 6:53 PM, Joe Hurd wrote: > Hi Ramana, > > I've tried to be clearer in the article specification what the format > is for strings: > > http://www.gilith.com/research/opentheory/article.html#nameCommand > > Could you take a look and see if that answers your questions? Honestly, that is still cryptic to me, although it's quite possible you're saying everything you need to... First of all, what does it mean to obtain a string by matching a regular expression? I thought matching was a predicate on regular expressions and strings, i.e. regex -> string -> bool. So are you just trying to say the match will succeed? And then you're left with the string, you discard the quotes, but what about the slashes inside the string? Unless matching a regex means something more special that would deal with the slashes... > > Cheers, > > Joe > > On Mon, Jan 10, 2011 at 7:21 AM, Ramana Kumar wrote: >> It appears that the quoted string command allows (requires) special >> characters to be escaped. >> For example, bool.art from bool-1.0 contains the following line, literally: >> >> "Data.Bool./\\" >> >> Is that name 'Data.Bool./\' or 'Data.Bool./\\'? >> >> The article format specification is at best unclear about this. >> Reading the specification literally, it looks like you get a command >> "s" (the quotation marks are literal characters and between them is a >> variable) and interpret it as Name s, not Name (parse_as_string s). Of >> course it does say that the variable stands for a string, and maybe >> that's supposed to be the clue that it might contain character >> escapes... >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 19:19:49 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 19:19:49 +0000 Subject: [opentheory-users] Fwd: [Hol-checkins] SF.net SVN: hol:[8845] HOL/src/opentheory In-Reply-To: References: Message-ID: Cool - just always go for the latest HOL version (I just checked in some changes and an additional example). On Mon, Jan 10, 2011 at 6:58 PM, Joe Hurd wrote: > Hi Ramana, > > This looks excellent - I will give it a go as soon as I get some time. > > Cheers, > > Joe > > On Mon, Jan 10, 2011 at 9:35 AM, Ramana Kumar wrote: >> My new implementation of the article reader for HOL4 (svn r8845) now >> successfully reads bool-1.0 (although I didn't check all the theorems >> were there - it looks reasonable, though). >> >> In the HOL repo, src/opentheory/selftest.sml is an example of how to >> use the reader, and src/opentheory/Opentheory.sig has some descriptive >> comments. >> >> >> ---------- Forwarded message ---------- >> From: ? >> Date: Mon, Jan 10, 2011 at 5:32 PM >> Subject: [Hol-checkins] SF.net SVN: hol:[8845] HOL/src/opentheory >> To: hol-checkins at lists.sf.net >> >> >> Revision: 8845 >> ? ? ? ? ?http://hol.svn.sourceforge.net/hol/?rev=8845&view=rev >> Author: ? xrchz >> Date: ? ? 2011-01-10 17:32:29 +0000 (Mon, 10 Jan 2011) >> >> Log Message: >> ----------- >> Complete rewrite of Opentheory reader >> >> It now successfully reads the package bool-1.0 in the gilith repository, >> and that is the selftest (only runs if you have opentheory installed). >> >> The selftest file is also an example of the work you might need to do to >> read an opentheory article that defines constants that are already >> defined in HOL. >> >> When the article is only going to define new things, the work would >> likely be less, although some helper functions (TODO) in the Opentheory >> module would make it easier. >> >> Modified Paths: >> -------------- >> ? ?HOL/src/opentheory/Opentheory.sig >> ? ?HOL/src/opentheory/Opentheory.sml >> ? ?HOL/src/opentheory/selftest.sml >> >> Modified: HOL/src/opentheory/Opentheory.sig >> =================================================================== >> --- HOL/src/opentheory/Opentheory.sig ? 2011-01-10 06:01:44 UTC (rev 8844) >> +++ HOL/src/opentheory/Opentheory.sig ? 2011-01-10 17:32:29 UTC (rev 8845) >> @@ -1,12 +1,51 @@ >> ?signature Opentheory = sig >> - ?type thms ? = Thm.thm Net.net >> - ?type types ?= (string, Type.hol_type list -> Type.hol_type) Redblackmap.dict >> - ?type consts = (string, Type.hol_type -> Term.term) Redblackmap.dict >> - ?val empty_thms ? ? : thms >> - ?val empty_types ? ?: types >> - ?val empty_consts ? : consts >> - ?val thmsFromList ? : Thm.thm list -> thms >> - ?val typesFromList ?: (string * (Type.hol_type list -> >> Type.hol_type)) list -> types >> - ?val constsFromList : (string * (Type.hol_type -> Term.term)) list -> consts >> - ?val read_article ? : TextIO.instream -> >> {thms:thms,types:types,consts:consts} -> Thm.thm list >> +type term = Term.term type hol_type = Type.hol_type type thm = Thm.thm >> +type ('a,'b) dict = ('a,'b) Redblackmap.dict >> + >> +(* maps between OpenTheory names and HOL4 names: *) >> +type thy_tyop ?= {Thy:string,Tyop:string} >> +type thy_const = {Thy:string,Name:string} >> +type 'a to_ot ?= ('a,string) dict >> +type 'a from_ot= (string,'a) dict >> +val tyop_to_ot ? : unit -> thy_tyop to_ot >> +val tyop_from_ot : unit -> thy_tyop from_ot >> +val const_to_ot ?: unit -> thy_const to_ot >> +val const_from_ot: unit -> thy_const from_ot >> + >> +(* record of data an article reader must provide: *) >> +type reader = { >> + ?tyops ?: (string, {axiom:thm, args:hol_type list, rep:string, abs:string} -> >> + ? ? ? ? ? ? ? ? ? ?{rep_abs:thm, abs_rep:thm, rep:term, abs:term, >> tyop:thy_tyop}) >> + ? ? ? ? ? dict, >> + ?consts : (string, term -> {const:thy_const, def:thm}) dict, >> + ?axioms : thm Net.net -> (term list * term) -> thm} >> + >> +(* >> +tyops are type operators the article will define, indexed by their OpenTheory >> +names. Each name is mapped to a function that does something equivalent to >> +defining the new type. Each function is provided the type axiom, a list of >> +arguments (type variables) for the type operator in the desired order, and the >> +OpenTheory names of the rep and abs constants. It must return the new type >> +operator, the rep and abs constants, and the type bijection theorems. >> +If axiom = |- P t then these are: >> + ?abs_rep = |- (!a. abs (rep a) = a) >> + ?rep_abs = |- (!r. P r = (rep(abs r) = r)) >> + >> +consts are constants the article will define, indexed by their OpenTheory >> +names. Each name is mapped to a function that does something equivalent to >> +defining the new constant. Each function is provided the right hand side rhs of >> +the definition and must return the name of the constant and an equational >> +theorem |- const = rhs. >> + >> +axioms are theorems that the article depends on about possibly both input >> +and output tyops and constants. They are represented by a function that takes >> +the collection of theorems the article has already proved, represented by a >> +conclusion-indexed net, and a pair (h,c) representing the desired axiom, and >> +must return a theorem h |- c. >> +*) >> + >> +val raw_read_article : {tyop_from_ot:thy_tyop from_ot, >> + ? ? ? ? ? ? ? ? ? ? ? ?const_from_ot:thy_const from_ot} >> + ? ? ? ? ? -> TextIO.instream -> reader -> thm list >> +val read_article ? ? : string -> reader -> thm list >> ?end >> >> Modified: HOL/src/opentheory/Opentheory.sml >> =================================================================== >> --- HOL/src/opentheory/Opentheory.sml ? 2011-01-10 06:01:44 UTC (rev 8844) >> +++ HOL/src/opentheory/Opentheory.sml ? 2011-01-10 17:32:29 UTC (rev 8845) >> @@ -1,221 +1,162 @@ >> ?structure Opentheory :> Opentheory = struct >> >> -val ERR = Feedback.mk_HOL_ERR "Opentheory" >> +open boolSyntax HolKernel Parse >> >> +local open Drule Conv in >> + ?fun DEDUCT_ANTISYM th1 th2 = >> + ? ?IMP_ANTISYM_RULE >> + ? ? ?(DISCH (concl th2) th1) >> + ? ? ?(DISCH (concl th1) th2) >> + ?fun absThm (v,tu) = let >> + ? ?val (t,u) = dest_eq(concl tu) >> + ? ?val vt = mk_abs(v,t) >> + ? ?val vu = mk_abs(v,u) >> + ? ?val vtvu = mk_eq(vt,vu) >> + ? ?val x = FUN_EQ_CONV vtvu >> + ? ?val x = CONV_RULE (RAND_CONV (QUANT_CONV (LAND_CONV BETA_CONV))) x >> + ? ?val x = CONV_RULE (RAND_CONV (QUANT_CONV (RAND_CONV BETA_CONV))) x >> + ?in EQ_MP (SYM x) (GEN v tu) end >> +end >> + >> +val ERR = mk_HOL_ERR "Opentheory" >> + >> ?structure Map = Redblackmap >> -type thms ? = Thm.thm Net.net >> -type types ?= (string, Type.hol_type list -> Type.hol_type) Map.dict >> -type consts = (string, Type.hol_type -> Term.term) Map.dict >> +type ('a,'b) dict = ('a,'b) Map.dict >> >> -val empty_thms ? ? = Net.empty >> -val empty_types ? ?= Map.mkDict String.compare >> -val empty_consts ? = Map.mkDict String.compare >> -val thmsFromList ? = List.foldl (fn (th,n) => Net.insert(Thm.concl >> th,th) n) empty_thms >> -val typesFromList ?= Map.fromList String.compare >> -val constsFromList = Map.fromList String.compare >> +type thy_tyop ?= {Thy:string,Tyop:string} >> +type thy_const = {Thy:string,Name:string} >> +type 'a to_ot ?= ('a,string) dict >> +type 'a from_ot= (string,'a) dict >> +fun lex_cmp c (f1,f2) (x1,x2) = >> + ?case c(f1 x1,f1 x2) of EQUAL => c(f2 x1,f2 x2) | z => z >> +val thy_tyop_cmp ?= lex_cmp String.compare (#Tyop,#Thy) >> +val thy_const_cmp = lex_cmp String.compare (#Name,#Thy) >> +val the_tyop_to_ot ? = ref (Map.mkDict thy_tyop_cmp) >> +val the_tyop_from_ot = ref (Map.mkDict String.compare) >> +val the_const_to_ot ?= ref (Map.mkDict thy_const_cmp) >> +val the_const_from_ot= ref (Map.mkDict String.compare) >> +fun tyop_to_ot() ? = !the_tyop_to_ot >> +fun tyop_from_ot() = !the_tyop_from_ot >> +fun const_to_ot() ?= !the_const_to_ot >> +fun const_from_ot()= !the_const_from_ot >> >> ?datatype object >> ?= ONum of int >> ?| OName of string >> ?| OList of object list >> -| OTypeOp of string >> -| OType of Type.hol_type >> -| OConst of string >> -| OVar of Term.term >> -| OTerm of Term.term >> -| OThm of Thm.thm >> +| OTypeOp of thy_tyop >> +| OType of hol_type >> +| OConst of thy_const >> +| OVar of term >> +| OTerm of term >> +| OThm of thm >> >> -datatype command >> -= Num of int >> -| Name of string >> -| AbsTerm >> -| AbsThm >> -| AppTerm >> -| AppThm >> -| Assume >> -| Axiom >> -| BetaConv >> -| Cons >> -| Const >> -| ConstTerm >> -| DeductAntisym >> -| Def >> -| DefineConst >> -| DefineTypeOp >> -| EqMp >> -| Nil >> -| OpType >> -| Pop >> -| Ref >> -| Refl >> -| Remove >> -| Subst >> -| Thm >> -| TypeOp >> -| Var >> -| VarTerm >> -| VarType >> +type reader = >> + ? {tyops ?: (string, {axiom:thm, args:hol_type list, rep:string, >> abs:string} -> >> + ? ? ? ? ? ? ? ? ? ? ?{rep_abs:thm, abs_rep:thm, rep:term, abs:term, >> tyop:thy_tyop}) >> + ? ? ? ? ? ? dict, >> + ? ?consts : (string, term -> {const:thy_const, def:thm}) dict, >> + ? ?axioms : thm Net.net -> (term list * term) -> thm} >> >> -fun st_ (st,{stack,dict,thms}) = {stack=st,dict=dict,thms=thms} >> -fun push (ob,state) = st_ (ob::(#stack state),state) >> - >> -fun find_thm thms (h,c) = let >> - ?val candidates = Net.index c thms >> - ?fun equal thm = let >> - ? ?val c' = Thm.concl thm >> - ? ?val thm' = Drule.PART_MATCH Lib.I thm (#2(boolSyntax.strip_forall c)) >> - ?in Lib.set_eq h (Thm.hyp thm') end handle Feedback.HOL_ERR _ => false >> - ?val SOME th = List.find equal candidates >> -in th end >> - >> -fun find_const consts (n,t) = Map.find(consts,n) t >> -handle Map.NotFound => Term.mk_const(n,t) >> -handle Feedback.HOL_ERR _ => raise ERR "find_const" ("need "^n^" of >> type "^(Parse.type_to_string t)) >> - >> -local open Thm Drule in >> -fun DEDUCT_ANTISYM th1 th2 = >> - ?IMP_ANTISYM_RULE >> - ? ?(DISCH (concl th1) th2) >> - ? ?(DISCH (concl th2) th1) >> +fun st_(st,{stack,dict,thms}) = {stack=st,dict=dict,thms=thms} >> +fun push (ob,st) = st_(ob::(#stack st),st) >> +local open Substring in >> + ?val trimlr = fn s => string(trimr 1 (triml 1 (full s))) >> + ?val trimr ?= fn s => string(trimr 1 (full s)) >> ?end >> >> -val unOTermls = List.map (fn OTerm t => t) >> -val unOTypels = List.map (fn OType t => t) >> -val unONamels = List.map (fn OName n => n) >> - >> -fun find_type types (t,ls) = let >> - ?val ls = unOTypels ls >> -in >> - ?(Map.find(types,t)) ls >> - ?handle Map.NotFound => let >> - ? ?val s = Parse.type_to_string(Type.mk_type(t,ls)) >> - ? ?handle Feedback.HOL_ERR _ => >> - ? ?(* PolyML.makestring (t, (Map.listItems types)) *) >> - ? ?("TyOp = "^t^", Args = "^(String.concatWith ", " (List.map >> Parse.type_to_string ls))) >> - ?in raise ERR "find_type" ("need "^s) end >> -end >> - >> -exception Comment >> - >> -fun >> - ?parse_line "absTerm" ? ? ? = AbsTerm >> -| parse_line "absThm" ? ? ? ?= AbsThm >> -| parse_line "appTerm" ? ? ? = AppTerm >> -| parse_line "appThm" ? ? ? ?= AppThm >> -| parse_line "assume" ? ? ? ?= Assume >> -| parse_line "axiom" ? ? ? ? = Axiom >> -| parse_line "betaConv" ? ? ?= BetaConv >> -| parse_line "cons" ? ? ? ? ?= Cons >> -| parse_line "const" ? ? ? ? = Const >> -| parse_line "constTerm" ? ? = ConstTerm >> -| parse_line "deductAntisym" = DeductAntisym >> -| parse_line "def" ? ? ? ? ? = Def >> -| parse_line "defineConst" ? = DefineConst >> -| parse_line "defineTypeOp" ?= DefineTypeOp >> -| parse_line "eqMp" ? ? ? ? ?= EqMp >> -| parse_line "nil" ? ? ? ? ? = Nil >> -| parse_line "opType" ? ? ? ?= OpType >> -| parse_line "pop" ? ? ? ? ? = Pop >> -| parse_line "ref" ? ? ? ? ? = Ref >> -| parse_line "refl" ? ? ? ? ?= Refl >> -| parse_line "remove" ? ? ? ?= Remove >> -| parse_line "subst" ? ? ? ? = Subst >> -| parse_line "thm" ? ? ? ? ? = Thm >> -| parse_line "typeOp" ? ? ? ?= TypeOp >> -| parse_line "var" ? ? ? ? ? = Var >> -| parse_line "varTerm" ? ? ? = VarTerm >> -| parse_line "varType" ? ? ? = VarType >> -| parse_line s = let >> - ? ?val c = String.sub(s,0) >> - ?in if c = #"\"" then Name (String.substring(s,1,String.size s -2)) else >> - ? ? if Char.isDigit c then Num (Option.valOf (Int.fromString s)) >> - ? ? else raise Comment >> - ?end >> - >> -fun read_article file {types,consts,thms} = let >> - ?val find_asm ? = find_thm thms >> - ?val find_const = find_const consts >> - ?val find_type ?= find_type types >> - ?fun f (Num i) ?st = push(ONum i,st) >> - ? ?| f (Name s) st = push(OName s,st) >> - ? ?| f AbsTerm ?(st as {stack=OTerm b::OVar v::os,...}) ?= >> st_(OTerm(Term.mk_abs(v,b))::os,st) >> - ? ?| f AppTerm ?(st as {stack=OTerm x::OTerm f::os,...}) = >> st_(OTerm(Term.mk_comb(f,x))::os,st) >> - ? ?| f AppThm ? (st as {stack=OThm xy::OThm fg::os,...}) = let >> - ? ? ? ?val (f,g) = boolSyntax.dest_eq(Thm.concl fg) >> - ? ? ? ?val (x,y) = boolSyntax.dest_eq(Thm.concl xy) >> - ? ? ? ?val fxgx ?= Thm.AP_THM fg x >> - ? ? ? ?val gxgy ?= Thm.AP_TERM g xy >> - ? ? ?in st_(OThm(Thm.TRANS fxgx gxgy)::os,st) end >> - ? ?| f Assume ? ? ? ?(st as {stack=OTerm t::os,...}) ? ? ? ? ? = >> st_(OThm(Thm.ASSUME t)::os,st) >> - ? ?| f Axiom ? ? ? ? (st as {stack=OTerm t::OList ts::os,...}) = >> st_(OThm(find_asm(unOTermls ts,t))::os,st) >> - ? ?| f BetaConv ? ? ?(st as {stack=OTerm t::os,...}) ? ? ? ? ? = >> st_(OThm(Thm.BETA_CONV t)::os,st) >> - ? ?| f Cons ? ? ? ? ?(st as {stack=OList t::h::os,...}) ? ? ? ?= >> st_(OList(h::t)::os,st) >> - ? ?| f Const ? ? ? ? (st as {stack=OName n::os,...}) ? ? ? ? ? = >> st_(OConst n::os,st) >> - ? ?| f ConstTerm ? ? (st as {stack=OType t::OConst c::os,...}) = >> st_(OTerm(find_const (c,t))::os,st) >> - ? ?| f DeductAntisym (st as {stack=OThm t1::OThm t2::os,...}) ?= >> st_(OThm(DEDUCT_ANTISYM t1 t2)::os,st) >> - ? ?| f Def ? ? ? ? ? {stack=ONum k::x::os,dict,thms} ? ? ? ? ? = >> {stack=x::os,dict=Map.insert(dict,k,x),thms=thms} >> - ? ?| f DefineConst ? (st as {stack=OTerm t::OName n::os,...}) ?= let >> - ? ? ? ?val t = boolSyntax.mk_eq(Term.mk_var(n,Term.type_of t),t) >> - ? ? ? ?val def = Definition.new_definition(n,t) >> - ? ? ? ?handle Feedback.HOL_ERR _ => raise ERR "read_article" >> ("DefineConst "^n^" by "^Parse.term_to_string t^" failed") >> - ? ? ?in st_(OThm def::OConst n::os,st) end >> - ? ?| f DefineTypeOp ?(st as {stack=OThm th::OList ls::OName >> rep::OName abs::OName n::os,...}) = let >> - ? ? ? ?val ls = unONamels ls >> - ? ? ? ?val sorted = Lib.sort (Lib.curry (Lib.equal LESS o String.compare)) ls >> - ? ? ? ?val s = let fun f (a,a',s) = if a = a' then s else let >> - ? ? ? ? ? ? ? ? ? ? ?val a = Type.mk_vartype a >> - ? ? ? ? ? ? ? ? ? ? ?val a' = Type.mk_vartype a' >> - ? ? ? ? ? ? ? ? ? ? ?val op |-> = Lib.|-> infix |-> >> - ? ? ? ? ? ? ? ? ? ?in (a |-> a')::(a' |-> a)::s end >> - ? ? ? ? ? ? ? ?in ListPair.foldlEq f [] (ls,sorted) end >> - ? ? ? ?val th = Thm.INST_TYPE s th >> - ? ? ? ?val Pt = Thm.concl th >> - ? ? ? ?val (P,t) = Term.dest_comb(Pt) >> - ? ? ? ?val th = Thm.EXISTS(boolSyntax.mk_exists(t,Pt),t) th >> - ? ? ? ?val tyax = Definition.new_type_definition(n,th) >> - ? ? ? ?val th = Drule.define_new_type_bijections >> {name=n^"_repfns",ABS=abs,REP=rep,tyax=tyax} >> - ? ? ? ?val th1 = Drule.SPEC_ALL (Thm.CONJUNCT1 th) >> - ? ? ? ?val th2 = Drule.SPEC_ALL (Thm.CONJUNCT2 th) >> - ? ? ?in st_(OThm th2::OThm ?th1::OConst rep::OConst abs::OTypeOp n::os,st) end >> - ? ?| f EqMp ? (st as {stack=OThm fg::OThm f::os,...}) ? ? = >> st_(OThm(Thm.EQ_MP fg f)::os,st) >> - ? ?| f Nil ? ?st ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?= push(OList [],st) >> - ? ?| f OpType (st as {stack=OList ls::OTypeOp t::os,...}) = >> st_(OType(find_type(t,ls))::os,st) >> - ? ?| f Pop ? ?(st as {stack=x::os,...}) ? ? ? ? ? ? ? ? ? = st_(os,st) >> - ? ?| f Ref ? ?(st as {stack=ONum k::os,dict,...}) ? ? ? ? = >> st_(Map.find(dict,k)::os,st) >> - ? ?| f Refl ? (st as {stack=OTerm t::os,...}) ? ? ? ? ? ? = >> st_(OThm(Thm.REFL t)::os,st) >> - ? ?| f Remove {stack=ONum k::os,dict,thms} ? ? ? ? ? ? ? ?= let >> +fun raw_read_article {tyop_from_ot,const_from_ot} input >> {tyops,consts,axioms} = let >> + ?val ERR = ERR "read_article" >> + ?fun unOTermls c = List.map (fn OTerm t => t | _ => raise ERR (c^" >> failed to pop a list of terms")) >> + ?fun unOTypels c = List.map (fn OType t => t | _ => raise ERR (c^" >> failed to pop a list of types")) >> + ?fun ot_to_const c s = Map.find(const_from_ot,s) >> + ?handle Map.NotFound => raise ERR (c^": no map from "^s^" to a constant") >> + ?fun ot_to_tyop ?c s = Map.find(tyop_from_ot ,s) >> + ?handle Map.NotFound => raise ERR (c^": no map from "^s^" to a type operator") >> + ?fun f "absTerm"(st as {stack=OTerm b::OVar v::os,...}) = >> st_(OTerm(mk_abs(v,b))::os,st) >> + ? ?| f "absThm" (st as {stack=OThm th::OVar v::os,...}) = >> (st_(OThm(absThm(v,th))::os,st) >> + ? ? ?handle HOL_ERR e => raise ERR ("absThm: failed with "^format_ERR e)) >> + ? ?| f "appTerm"(st as {stack=OTerm x::OTerm f::os,...})= >> st_(OTerm(mk_comb(f,x))::os,st) >> + ? ?| f "appThm" (st as {stack=OThm xy::OThm fg::os,...})= let >> + ? ? ? ?val (f,g) = dest_eq(concl fg) >> + ? ? ? ?val (x,y) = dest_eq(concl xy) >> + ? ? ? ?val fxgx ?= AP_THM fg x >> + ? ? ? ?val gxgy ?= AP_TERM g xy >> + ? ? ?in st_(OThm(TRANS fxgx gxgy)::os,st) end >> + ? ?| f "assume" ? ? ? (st as {stack=OTerm t::os,...}) ? ? ? ? ?= >> st_(OThm(ASSUME t)::os,st) >> + ? ?| f "axiom" ? ? ? ?(st as {stack=OTerm t::OList ts::os,thms,...}) >> = st_(OThm(axioms thms (unOTermls "axiom" ts,t))::os,st) >> + ? ?| f "betaConv" ? ? (st as {stack=OTerm t::os,...}) ? ? ? ? ?= >> st_(OThm(BETA_CONV t)::os,st) >> + ? ?| f "cons" ? ? ? ? (st as {stack=OList t::h::os,...}) ? ? ? = >> st_(OList(h::t)::os,st) >> + ? ?| f "const" ? ? ? ?(st as {stack=OName n::os,...}) ? ? ? ? ?= >> st_(OConst (ot_to_const "const" n)::os,st) >> + ? ?| f "constTerm" ? ?(st as {stack=OType Ty::OConst {Thy,Name}::os,...}) >> + ? ? ? ? ? ? ? ? ? ? = st_(OTerm(mk_thy_const >> {Ty=Ty,Thy=Thy,Name=Name})::os,st) >> + ? ?| f "deductAntisym"(st as {stack=OThm t1::OThm t2::os,...}) = >> st_(OThm(DEDUCT_ANTISYM t1 t2)::os,st) >> + ? ?| f "def" ? ? ? ? {stack=ONum k::x::os,dict,thms} ? ? ? ? ? = >> {stack=x::os,dict=Map.insert(dict,k,x),thms=thms} >> + ? ?| f "defineConst" (st as {stack=OTerm t::OName n::os,...}) ?= let >> + ? ? ? ?val {const,def} = Map.find(consts,n) t >> + ? ? ? ?handle Map.NotFound => raise ERR ("defineConst: no map from >> "^n^" to a definition function") >> + ? ? ?in st_(OThm def::OConst const::os,st) end >> + ? ?| f "defineTypeOp" ?(st as {stack=OThm th::OList ls::OName >> rep::OName abs::OName n::os,...}) = let >> + ? ? ? ?val ls = List.map (fn OName s => mk_vartype s | _ => raise >> ERR "defineTypeOp failed to pop a list of names") ls >> + ? ? ? ?val {abs,rep,abs_rep,rep_abs,tyop} = Map.find(tyops,n) >> {axiom=th,args=ls,rep=rep,abs=abs} >> + ? ? ? ?val {Thy,Name,...} = dest_thy_const rep val rep = {Thy=Thy,Name=Name} >> + ? ? ? ?val {Thy,Name,...} = dest_thy_const abs val abs = {Thy=Thy,Name=Name} >> + ? ? ?in st_(OThm rep_abs::OThm abs_rep::OConst rep::OConst >> abs::OTypeOp tyop::os,st) end >> + ? ?| f "eqMp" ? (st as {stack=OThm f::OThm fg::os,...}) ? ? = >> (st_(OThm(EQ_MP fg f)::os,st) >> + ? ? ?handle HOL_ERR _ => raise ERR ("EqMp failed on "^thm_to_string >> fg^" and "^thm_to_string f)) >> + ? ?| f "nil" ? ?st ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?= >> push(OList [],st) >> + ? ?| f "opType" (st as {stack=OList ls::OTypeOp {Thy,Tyop}::os,...}) >> + ? ? ? ? ? ? ? = >> st_(OType(mk_thy_type{Thy=Thy,Tyop=Tyop,Args=unOTypels "opType" >> ls})::os,st) >> + ? ?| f "pop" ? ?(st as {stack=x::os,...}) ? ? ? ? ? ? ? ? ? = st_(os,st) >> + ? ?| f "ref" ? ?(st as {stack=ONum k::os,dict,...}) ? ? ? ? = >> st_(Map.find(dict,k)::os,st) >> + ? ?| f "refl" ? (st as {stack=OTerm t::os,...}) ? ? ? ? ? ? = >> st_(OThm(REFL t)::os,st) >> + ? ?| f "remove" {stack=ONum k::os,dict,thms} ? ? ? ? ? ? ? ?= let >> ? ? ? ? val (dict,x) = Map.remove(dict,k) >> ? ? ? in {stack=x::os,dict=dict,thms=thms} end >> - ? ?| f Subst ?(st as {stack=OThm th::OList[OList tys,OList >> tms]::os,...}) = let >> - ? ? ? ?val tys = List.map (fn OList [OName a, OType t] => >> {redex=Type.mk_vartype a, residue=t}) tys >> - ? ? ? ?val tms = List.map (fn OList [OVar v, OTerm t] => {redex=v, >> residue=t}) tms >> - ? ? ? ?val th = Thm.INST_TYPE tys th >> - ? ? ? ?val th = Thm.INST tms th >> + ? ?| f "subst" ?(st as {stack=OThm th::OList[OList tys,OList >> tms]::os,...}) = let >> + ? ? ? ?val tys = List.map (fn OList [OName a, OType t] => >> {redex=mk_vartype a, residue=t} >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? | _ => raise ERR "subst failed to pop a >> list of [name,type] pairs") tys >> + ? ? ? ?val tms = List.map (fn OList [OVar v, OTerm t] => {redex=v, residue=t} >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? | _ => raise ERR "subst failed to pop a >> list of [var,term] pairs") tms >> + ? ? ? ?val th = INST_TYPE tys th >> + ? ? ? ?val th = INST tms th >> ? ? ? in st_(OThm th::os,st) end >> - ? ?| f Thm ? ?{stack=OTerm c::OList ls::OThm th::os,dict,thms} = let >> - ? ? ? ?val th = Thm.EQ_MP (Thm.ALPHA (Thm.concl th) c) th >> + ? ?| f "thm" ? ?{stack=OTerm c::OList ls::OThm th::os,dict,thms} = let >> + ? ? ? ?val th = EQ_MP (ALPHA (concl th) c) th >> + ? ? ? ?handle HOL_ERR _ => raise ERR "thm: desired conclusion not >> alpha-equivalent to theorem's conclusion" >> ? ? ? ? fun ft (OTerm h, th) = let >> - ? ? ? ? ?val c = Thm.concl th >> - ? ? ? ? ?val th = Thm.DISCH h th >> - ? ? ? ? ?val c' = Thm.concl th >> + ? ? ? ? ?val c = concl th >> + ? ? ? ? ?val th = DISCH h th >> + ? ? ? ? ?val c' = concl th >> ? ? ? ? in >> - ? ? ? ? ?if Term.aconv c c' then >> + ? ? ? ? ?if aconv c c' then >> ? ? ? ? ? ? Drule.ADD_ASSUM h th >> ? ? ? ? ? else let >> ? ? ? ? ? ? val (h',_) = boolSyntax.dest_imp c' >> - ? ? ? ? ? ?val h'h = Thm.ALPHA h' h >> + ? ? ? ? ? ?val h'h = ALPHA h' h >> ? ? ? ? ? ? val th = Drule.SUBS_OCCS [([1],h'h)] th >> ? ? ? ? ? in Drule.UNDISCH th end >> - ? ? ? ?end >> + ? ? ? ?end | ft _ = raise ERR "thm failed to pop a list of terms" >> ? ? ? ? val th = List.foldl ft th ls >> - ? ? ?in {stack=os,dict=dict,thms=th::thms} end >> - ? ?| f TypeOp ?(st as {stack=OName n::os,...}) ? ? ? ? ?= >> st_(OTypeOp n::os,st) >> - ? ?| f Var ? ? (st as {stack=OType t::OName n::os,...}) = >> st_(OVar(Term.mk_var(n,t))::os,st) >> - ? ?| f VarTerm (st as {stack=OVar t::os,...}) ? ? ? ? ? = st_(OTerm t::os,st) >> - ? ?| f VarType (st as {stack=OName n::os,...}) ? ? ? ? ?= >> st_(OType(Type.mk_vartype n)::os,st) >> - ?fun stripnl s = let open Substring in string(trimr 1 (full s)) end >> - ?fun loop x = case TextIO.inputLine file of >> - ? ?NONE => x before TextIO.closeIn(file) >> - ?| SOME line => loop (f (parse_line (stripnl line)) x handle Comment => x) >> -in #thms (loop {stack=[],dict=Map.mkDict(Int.compare),thms=[]}) end >> + ? ? ?in {stack=os,dict=dict,thms=Net.insert(concl th,th)thms} end >> + ? ?| f "typeOp" ?(st as {stack=OName n::os,...}) ? ? ? ? ?= >> st_(OTypeOp (ot_to_tyop "typeOp" n)::os,st) >> + ? ?| f "var" ? ? (st as {stack=OType t::OName n::os,...}) = >> st_(OVar(mk_var(n,t))::os,st) >> + ? ?| f "varTerm" (st as {stack=OVar t::os,...}) ? ? ? ? ? = >> st_(OTerm t::os,st) >> + ? ?| f "varType" (st as {stack=OName n::os,...}) ? ? ? ? ?= >> st_(OType(mk_vartype n)::os,st) >> + ? ?| f s st = let val c = String.sub(s,0) open Char Option Int >> + ? ? ?in if c = #"\"" then push(OName(valOf(String.fromString (trimlr >> s))),st) else >> + ? ? ? ? if isDigit c then push(ONum(valOf(fromString s)),st) else >> + ? ? ? ? if c = #"#" then st else >> + ? ? ? ? raise ERR ("Unknown command: "^s) >> + ? ? ?end >> + ?fun loop x = case TextIO.inputLine input of >> + ? ?NONE => x before TextIO.closeIn(input) >> + ?| SOME line => loop (f (trimr line) x) >> +in Net.listItems (#thms (loop >> {stack=[],dict=Map.mkDict(Int.compare),thms=Net.empty})) end >> + >> +fun read_article s r = >> + ?raw_read_article >> + ? ?{tyop_from_ot=tyop_from_ot(), >> + ? ? const_from_ot=const_from_ot()} >> + ? ?(TextIO.openIn s) r >> ?end >> >> Modified: HOL/src/opentheory/selftest.sml >> =================================================================== >> --- HOL/src/opentheory/selftest.sml ? ? 2011-01-10 06:01:44 UTC (rev 8844) >> +++ HOL/src/opentheory/selftest.sml ? ? 2011-01-10 17:32:29 UTC (rev 8845) >> @@ -1,17 +1,63 @@ >> -open Opentheory >> +open Opentheory boolTheory boolLib bossLib HolKernel >> ?fun cmd pkg out = ("opentheory info --article -o "^out^" "^pkg) >> -val pkg = "bool-def-1.0" >> -val tmp = OS.FileSys.tmpName() >> -val _ = if OS.Process.isSuccess(Systeml.system_ps (cmd pkg tmp)) then let >> -val thms = read_article (TextIO.openIn tmp) { >> - ?thms=empty_thms, >> +val pkg = "bool-1.0" >> +(* >> +show: "Data.Bool" >> +input type operators: -> bool >> +input constants: = select >> +assumptions: >> +defined constants: ! /\ ==> ? ?! \/ ~ cond let F T >> +axioms: >> + ?|- !t. (\x. t x) = t >> + ?|- !P x. P x ==> P ((select) P) >> + >> ? types=typesFromList >> ? [("bool",fn [] => Type.bool), >> ? ?("->",fn ls => Type.mk_type("fun",ls))], >> ? consts=constsFromList >> ? [("=",fn ty => Term.mk_const("=",ty)), >> - ? ("Data.Bool.select",fn ty => Term.mk_const("@",ty))]} >> -val thms = thmsFromList thms >> + ? ("Data.Bool.select",fn ty => Term.mk_const("@",ty))] >> +*) >> +val tmp = OS.FileSys.tmpName() >> +val _ = if OS.Process.isSuccess(Systeml.system_ps (cmd pkg tmp)) then let >> +val input = TextIO.openIn tmp >> +val tyop_from_ot = Redblackmap.fromList String.compare [ >> + ?("bool",{Thy="min",Tyop="bool"}), >> + ?("->",{Thy="min",Tyop="fun"})] >> +val const_from_ot = Redblackmap.fromList String.compare [ >> + ?("=",{Thy="min",Name="="}), >> + ?("Data.Bool.select",{Thy="min",Name="@"})] >> +val A = INST_TYPE[alpha|->mk_vartype"A",beta|->mk_vartype"B"] >> +val reader = { >> + ?tyops=Redblackmap.mkDict String.compare, >> + ?consts= >> + ?Redblackmap.fromList String.compare [ >> + ? ? ?("Data.Bool.!", fn _ => {const={Thy="bool",Name="!"},def=A FORALL_DEF}), >> + ? ? ?("Data.Bool./\\", let >> + ? ? ? ?val th = prove(``$/\ = \p q. (\f. f p q) = >> \f:bool->bool->bool. f T T``, >> + ? ? ? ? ? ? ? ? ? ? ? SRW_TAC [][AND_DEF,FUN_EQ_THM] THEN EQ_TAC >> THEN SRW_TAC [][]) >> + ? ? ? ?in fn _ => {const={Thy="bool",Name="/\\"},def=th} end), >> + ? ? ?("Data.Bool.==>",let >> + ? ? ? ?val th = METIS_PROVE [] ``$==> = \p q. p /\ q <=> p`` >> + ? ? ? ?in fn _ => {const={Thy="min",Name="==>"},def=th} end), >> + ? ? ?("Data.Bool.?", let >> + ? ? ? ? val th = prove(``$? = \P. !q. (!x. P x ==> q) ==> q``, >> + ? ? ? ? ? ? ? ? ? ? ? ?SRW_TAC [][EXISTS_DEF,FUN_EQ_THM,EQ_IMP_THM] THEN >> + ? ? ? ? ? ? ? ? ? ? ? ?FIRST_X_ASSUM MATCH_MP_TAC THEN METIS_TAC [SELECT_AX]) >> + ? ? ? ?in fn _ => {const={Thy="bool",Name="?"},def=A th} end), >> + ? ? ?("Data.Bool.?!", fn _ => {const={Thy="bool",Name="?!"},def=A >> EXISTS_UNIQUE_DEF}), >> + ? ? ?("Data.Bool.\\/", fn _ => {const={Thy="bool",Name="\\/"},def=OR_DEF}), >> + ? ? ?("Data.Bool.~", fn _ => {const={Thy="bool",Name="~"},def=NOT_DEF}), >> + ? ? ?("Data.Bool.cond", fn _ => >> {const={Thy="bool",Name="COND"},def=A COND_DEF}), >> + ? ? ?("Data.Bool.let", fn _ => {const={Thy="bool",Name="LET"},def=A LET_DEF}), >> + ? ? ?("Data.Bool.F", fn _ => {const={Thy="bool",Name="F"},def=F_DEF}), >> + ? ? ?("Data.Bool.T", fn _ => {const={Thy="bool",Name="T"},def=T_DEF})], >> + ?axioms=let open List Net Thm >> + ? ?fun ins th = insert(concl th,th) >> + ? ?val n = ins (A ETA_AX) (ins (A SELECT_AX) empty) >> + ? ?fun f _ (_,c) = hd (index c n) >> + ?in f end } >> +val thms = raw_read_article {tyop_from_ot=tyop_from_ot, >> const_from_ot=const_from_ot} input reader >> ?(* TODO: check that thms is the same set that opentheory >> ? ? ? ? ?says the package should have produced *) >> ?in () end else () >> >> >> This was sent by the SourceForge.net collaborative development >> platform, the world's largest Open Source development site. >> >> ------------------------------------------------------------------------------ >> Gaining the trust of online customers is vital for the success of any company >> that requires sensitive data to be transmitted over the Web. ? Learn how to >> best implement a security strategy that keeps consumers' information secure >> and instills the confidence they need to proceed with transactions. >> http://p.sf.net/sfu/oracle-sfdevnl >> _______________________________________________ >> Hol-checkins mailing list >> Hol-checkins at lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/hol-checkins >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 19:28:39 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 19:28:39 +0000 Subject: [opentheory-users] Isabelle In-Reply-To: References: Message-ID: Oh I see you mention Isabelle briefly at the end of your paper. On Mon, Jan 10, 2011 at 7:27 PM, Ramana Kumar wrote: > How much (and what) work would be necessary to extend OpenTheory > interoperability to Isabelle/HOL? > Is that a long-term goal of the project? > What about to non-HOL provers? I certainly imagine ideas from > OpenTheory might be used in an even more radical inter-logic theory > packaging system, but could that system in fact be a distant version > of OpenTheory itself? > From joe at gilith.com Mon Jan 10 19:37:39 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 11:37:39 -0800 Subject: [opentheory-users] quoted strings In-Reply-To: References: Message-ID: Hi Ramana, > First of all, what does it mean to obtain a string by matching a > regular expression? Good question: I've tightened up the language to "A name command is a string that matches the following regular expression:" > And then you're left with the string, you discard the quotes, but what > about the slashes inside the string? You leave the slashes in the string. The most important property here is that equality of names is the same as equality of the strings representing them. For example, the two names A.b and A\.b are different, so it is good that they are represented by different strings (because the slashes are left in). This is all that automatic tools for processing articles need to know. However, for the purpose of displaying names in human-readable form, the names might undergo some further processing, so A.b is actually treated as the name b in the namespace A, and A\.b is treated as the name A\.b in the global namespace, and as a result "show" tags might transform them differently. In my eyes an import tool falls into the "automatic tools" category, so I don't think you need to worry about the human readability angle. Does that help? Cheers, Joe From ramana.kumar at gmail.com Mon Jan 10 19:27:44 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 19:27:44 +0000 Subject: [opentheory-users] Isabelle Message-ID: How much (and what) work would be necessary to extend OpenTheory interoperability to Isabelle/HOL? Is that a long-term goal of the project? What about to non-HOL provers? I certainly imagine ideas from OpenTheory might be used in an even more radical inter-logic theory packaging system, but could that system in fact be a distant version of OpenTheory itself? From ramana.kumar at gmail.com Mon Jan 10 19:58:43 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 19:58:43 +0000 Subject: [opentheory-users] quoted strings In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 7:37 PM, Joe Hurd wrote: > Hi Ramana, > >> First of all, what does it mean to obtain a string by matching a >> regular expression? > > Good question: I've tightened up the language to > > "A name command is a string that matches the following regular expression:" > >> And then you're left with the string, you discard the quotes, but what >> about the slashes inside the string? > > You leave the slashes in the string. The most important property here Leave the slashes in the string? But bool.art uses Data.Bool./\\, but I think the intention is for the name to be Data.Bool./\, no? I'm at the moment using String.fromString on the line I get back from TextIO.inputLine - I can't keep track of where all these functions (including whatever's printing things out to my terminal) add and remove slashes. Would you expect to have to use fromString on a line from an article, or should the line itself be right? If the extra slash in bool.art is wrong, perhaps you got caught by an SML printer that was trying to print something it could read back in to a value. > is that equality of names is the same as equality of the strings > representing them. For example, the two names > > A.b > > and > > A\.b > > are different, so it is good that they are represented by different > strings (because the slashes are left in). > > This is all that automatic tools for processing articles need to know. > However, for the purpose of displaying names in human-readable form, > the names might undergo some further processing, so A.b is actually > treated as the name b in the namespace A, and A\.b is treated as the > name A\.b in the global namespace, and as a result "show" tags might > transform them differently. > > In my eyes an import tool falls into the "automatic tools" category, > so I don't think you need to worry about the human readability angle. > > Does that help? > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Mon Jan 10 20:14:16 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 12:14:16 -0800 Subject: [opentheory-users] quoted strings In-Reply-To: References: Message-ID: Hi Ramana, If you stick to the *representation* of names that I suggest, with the slashes left in, you will get the right properties of name equality. Any representation that gives you the same equality property is fine with me: indeed, OpenTheory uses a different one based on lists of strings. Removing slashes, so that A\.b and A.b have the same representation, will give you the wrong equality relation on names, so beware. Cheers, Joe On Mon, Jan 10, 2011 at 11:58 AM, Ramana Kumar wrote: > On Mon, Jan 10, 2011 at 7:37 PM, Joe Hurd wrote: >> Hi Ramana, >> >>> First of all, what does it mean to obtain a string by matching a >>> regular expression? >> >> Good question: I've tightened up the language to >> >> "A name command is a string that matches the following regular expression:" >> >>> And then you're left with the string, you discard the quotes, but what >>> about the slashes inside the string? >> >> You leave the slashes in the string. The most important property here > > Leave the slashes in the string? > But bool.art uses Data.Bool./\\, but I think the intention is for the > name to be Data.Bool./\, no? > I'm at the moment using String.fromString on the line I get back from > TextIO.inputLine - I can't keep track of where all these functions > (including whatever's printing things out to my terminal) add and > remove slashes. Would you expect to have to use fromString on a line > from an article, or should the line itself be right? > If the extra slash in bool.art is wrong, perhaps you got caught by an > SML printer that was trying to print something it could read back in > to a value. > >> is that equality of names is the same as equality of the strings >> representing them. For example, the two names >> >> A.b >> >> and >> >> A\.b >> >> are different, so it is good that they are represented by different >> strings (because the slashes are left in). >> >> This is all that automatic tools for processing articles need to know. >> However, for the purpose of displaying names in human-readable form, >> the names might undergo some further processing, so A.b is actually >> treated as the name b in the namespace A, and A\.b is treated as the >> name A\.b in the global namespace, and as a result "show" tags might >> transform them differently. >> >> In my eyes an import tool falls into the "automatic tools" category, >> so I don't think you need to worry about the human readability angle. >> >> Does that help? >> >> Cheers, >> >> Joe >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 20:36:27 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 20:36:27 +0000 Subject: [opentheory-users] quoted strings In-Reply-To: References: Message-ID: I'm starting to understand what you mean... Two questions: 1. What is the crazy regular expression in the article format description for? Why isn't it just ["].*["] ? (By that I mean any string of characters enclosed by quotation marks) 2. (This is a fiddly implementation question you might choose to ignore) I'd like to stick to the representation of names you suggested, which is, I think, that you represent a name by the string that if you would type it between quotes on an ML prompt would evaluate to the name. (That is, names are strings, and they are represented by similar but possibly different strings.) I think that means that I should not use String.fromString on the lines I get from the article, but I should convert (with String.toString) any names the user passes to the read_article function to my internal representation format. Sound right? On Mon, Jan 10, 2011 at 8:14 PM, Joe Hurd wrote: > Hi Ramana, > > If you stick to the *representation* of names that I suggest, with the > slashes left in, you will get the right properties of name equality. > Any representation that gives you the same equality property is fine > with me: indeed, OpenTheory uses a different one based on lists of > strings. > > Removing slashes, so that > > A\.b > > and > > A.b > > have the same representation, will give you the wrong equality > relation on names, so beware. > > Cheers, > > Joe > > On Mon, Jan 10, 2011 at 11:58 AM, Ramana Kumar wrote: >> On Mon, Jan 10, 2011 at 7:37 PM, Joe Hurd wrote: >>> Hi Ramana, >>> >>>> First of all, what does it mean to obtain a string by matching a >>>> regular expression? >>> >>> Good question: I've tightened up the language to >>> >>> "A name command is a string that matches the following regular expression:" >>> >>>> And then you're left with the string, you discard the quotes, but what >>>> about the slashes inside the string? >>> >>> You leave the slashes in the string. The most important property here >> >> Leave the slashes in the string? >> But bool.art uses Data.Bool./\\, but I think the intention is for the >> name to be Data.Bool./\, no? >> I'm at the moment using String.fromString on the line I get back from >> TextIO.inputLine - I can't keep track of where all these functions >> (including whatever's printing things out to my terminal) add and >> remove slashes. Would you expect to have to use fromString on a line >> from an article, or should the line itself be right? >> If the extra slash in bool.art is wrong, perhaps you got caught by an >> SML printer that was trying to print something it could read back in >> to a value. >> >>> is that equality of names is the same as equality of the strings >>> representing them. For example, the two names >>> >>> A.b >>> >>> and >>> >>> A\.b >>> >>> are different, so it is good that they are represented by different >>> strings (because the slashes are left in). >>> >>> This is all that automatic tools for processing articles need to know. >>> However, for the purpose of displaying names in human-readable form, >>> the names might undergo some further processing, so A.b is actually >>> treated as the name b in the namespace A, and A\.b is treated as the >>> name A\.b in the global namespace, and as a result "show" tags might >>> transform them differently. >>> >>> In my eyes an import tool falls into the "automatic tools" category, >>> so I don't think you need to worry about the human readability angle. >>> >>> Does that help? >>> >>> Cheers, >>> >>> Joe >>> >>> _______________________________________________ >>> opentheory-users mailing list >>> opentheory-users at gilith.com >>> http://www.gilith.com/mailman/listinfo/opentheory-users >>> >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 20:48:07 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 20:48:07 +0000 Subject: [opentheory-users] quoted strings In-Reply-To: References: Message-ID: I think actually it looks more like this. My object datatype includes a constructor OName of string, but should really be type name_rep = string OName : name_rep -> object then when reading an article, I get a string surrounded by quotes. by stripping the quotes I am left with a name_rep, since I am using the same representation of names as articles do, right? So I go ahead and push OName (trimquotes line) onto the stack. Then I have to define a function to get a name back from an object fun object_to_name (OName s) = name_rep_to_name s and I think we have: fun name_rep_to_name s = valOf(String.fromString) which would possibly explain why you have a restrictive regular expression for the articles: they need to be representations that won't make fromString return NONE? On Mon, Jan 10, 2011 at 8:36 PM, Ramana Kumar wrote: > I'm starting to understand what you mean... > > Two questions: > > 1. What is the crazy regular expression in the article format > description for? Why isn't it just > ?["].*["] > ? (By that I mean any string of characters enclosed by quotation marks) > > 2. (This is a fiddly implementation question you might choose to > ignore) I'd like to stick to the representation of names you > suggested, which is, I think, that you represent a name by the string > that if you would type it between quotes on an ML prompt would > evaluate to the name. (That is, names are strings, and they are > represented by similar but possibly different strings.) I think that > means that I should not use String.fromString on the lines I get from > the article, but I should convert (with String.toString) any names the > user passes to the read_article function to my internal representation > format. Sound right? > On Mon, Jan 10, 2011 at 8:14 PM, Joe Hurd wrote: >> Hi Ramana, >> >> If you stick to the *representation* of names that I suggest, with the >> slashes left in, you will get the right properties of name equality. >> Any representation that gives you the same equality property is fine >> with me: indeed, OpenTheory uses a different one based on lists of >> strings. >> >> Removing slashes, so that >> >> A\.b >> >> and >> >> A.b >> >> have the same representation, will give you the wrong equality >> relation on names, so beware. >> >> Cheers, >> >> Joe >> >> On Mon, Jan 10, 2011 at 11:58 AM, Ramana Kumar wrote: >>> On Mon, Jan 10, 2011 at 7:37 PM, Joe Hurd wrote: >>>> Hi Ramana, >>>> >>>>> First of all, what does it mean to obtain a string by matching a >>>>> regular expression? >>>> >>>> Good question: I've tightened up the language to >>>> >>>> "A name command is a string that matches the following regular expression:" >>>> >>>>> And then you're left with the string, you discard the quotes, but what >>>>> about the slashes inside the string? >>>> >>>> You leave the slashes in the string. The most important property here >>> >>> Leave the slashes in the string? >>> But bool.art uses Data.Bool./\\, but I think the intention is for the >>> name to be Data.Bool./\, no? >>> I'm at the moment using String.fromString on the line I get back from >>> TextIO.inputLine - I can't keep track of where all these functions >>> (including whatever's printing things out to my terminal) add and >>> remove slashes. Would you expect to have to use fromString on a line >>> from an article, or should the line itself be right? >>> If the extra slash in bool.art is wrong, perhaps you got caught by an >>> SML printer that was trying to print something it could read back in >>> to a value. >>> >>>> is that equality of names is the same as equality of the strings >>>> representing them. For example, the two names >>>> >>>> A.b >>>> >>>> and >>>> >>>> A\.b >>>> >>>> are different, so it is good that they are represented by different >>>> strings (because the slashes are left in). >>>> >>>> This is all that automatic tools for processing articles need to know. >>>> However, for the purpose of displaying names in human-readable form, >>>> the names might undergo some further processing, so A.b is actually >>>> treated as the name b in the namespace A, and A\.b is treated as the >>>> name A\.b in the global namespace, and as a result "show" tags might >>>> transform them differently. >>>> >>>> In my eyes an import tool falls into the "automatic tools" category, >>>> so I don't think you need to worry about the human readability angle. >>>> >>>> Does that help? >>>> >>>> Cheers, >>>> >>>> Joe >>>> >>>> _______________________________________________ >>>> opentheory-users mailing list >>>> opentheory-users at gilith.com >>>> http://www.gilith.com/mailman/listinfo/opentheory-users >>>> >>> >>> _______________________________________________ >>> opentheory-users mailing list >>> opentheory-users at gilith.com >>> http://www.gilith.com/mailman/listinfo/opentheory-users >>> >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > From joe at gilith.com Mon Jan 10 20:49:38 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 12:49:38 -0800 Subject: [opentheory-users] quoted strings In-Reply-To: References: Message-ID: Hi Ramana, > 1. What is the crazy regular expression in the article format > description for? Why isn't it just > ?["].*["] > ? (By that I mean any string of characters enclosed by quotation marks) Because slashes must be followed by a small set [\."] of escaped characters. For example, the name \c is illegal. > 2. (This is a fiddly implementation question you might choose to > ignore) I'd like to stick to the representation of names you > suggested, which is, I think, that you represent a name by the string > that if you would type it between quotes on an ML prompt would > evaluate to the name. (That is, names are strings, and they are > represented by similar but possibly different strings.) I think that > means that I should not use String.fromString on the lines I get from > the article, but I should convert (with String.toString) any names the > user passes to the read_article function to my internal representation > format. Sound right? I don't use these two functions myself, so I can't offer advice on how to use them. But what I would expect is that you would have functions: importName : openTheoryName -> holName exportName : holName -> openTheoryName that you would always use for converting between HOL4 names and OpenTheory names. Then the HOL4 user never needs to know that your internal representation of OpenTheory names (i.e., the type openTheoryName) is an ugly string filled with slashes, because Data.Bool./\\ is always converted to bool$/\ (or whatever it is). In practice, I think escaping is extremely rare: I can only think of Boolean conjunction and disjunction that use it, and they will certainly be included in any mapping between HOL4 and OpenTheory constant names. Cheers, Joe From ramana.kumar at gmail.com Mon Jan 10 20:57:14 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 20:57:14 +0000 Subject: [opentheory-users] quoted strings In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 8:49 PM, Joe Hurd wrote: > Hi Ramana, > >> 1. What is the crazy regular expression in the article format >> description for? Why isn't it just >> ?["].*["] >> ? (By that I mean any string of characters enclosed by quotation marks) > > Because slashes must be followed by a small set [\."] of escaped > characters. For example, the name \c is illegal. > >> 2. (This is a fiddly implementation question you might choose to >> ignore) I'd like to stick to the representation of names you >> suggested, which is, I think, that you represent a name by the string >> that if you would type it between quotes on an ML prompt would >> evaluate to the name. (That is, names are strings, and they are >> represented by similar but possibly different strings.) I think that >> means that I should not use String.fromString on the lines I get from >> the article, but I should convert (with String.toString) any names the >> user passes to the read_article function to my internal representation >> format. Sound right? > > I don't use these two functions myself, so I can't offer advice on how > to use them. But what I would expect is that you would have functions: I just want to say for the benefit of anyone else reading this that if my previous email was correct, then there is a simpler approach of using names to represent names (rather than a weird name_rep as in the article), and just doing a fromString once when you read the article line. Hmm... could I ask one more question actually, to be sure? You gave the example of the two names A\.b and and A.b. Suppose I have an article that defines two different constants with these names. Somewhere in the article file there must be lines that instruct the virtual machine to push those names onto the stack. What exactly would those lines look like? > > importName : openTheoryName -> holName > > exportName : holName -> openTheoryName > > that you would always use for converting between HOL4 names and > OpenTheory names. Then the HOL4 user never needs to know that your > internal representation of OpenTheory names (i.e., the type > openTheoryName) is an ugly string filled with slashes, because > Data.Bool./\\ is always converted to bool$/\ (or whatever it is). Well you're right, users won't even have to provide hol names because I intend to just have a big map that gets updated every time a theory defines new constants in HOL4 (so whoever wrote the script file for the theory would at some point say "add this open theory name mapping for my new constant to the database" but that's all...) HOL4 constant names aren't even strings :P (they are pairs of strings). > > In practice, I think escaping is extremely rare: I can only think of > Boolean conjunction and disjunction that use it, and they will > certainly be included in any mapping between HOL4 and OpenTheory > constant names. > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Mon Jan 10 21:02:05 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 13:02:05 -0800 Subject: [opentheory-users] quoted strings In-Reply-To: References: Message-ID: Hi Ramana, > Hmm... could I ask one more question actually, to be sure? > You gave the example of the two names A\.b and and A.b. > Suppose I have an article that defines two different constants with these names. > Somewhere in the article file there must be lines that instruct the > virtual machine to push those names onto the stack. > What exactly would those lines look like? The two command lines would be "A\.b" and "A.b" Two *different* names pushed onto the stack. Cheers, Joe From ramana.kumar at gmail.com Mon Jan 10 21:08:23 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 21:08:23 +0000 Subject: [opentheory-users] quoted strings In-Reply-To: References: Message-ID: So the OpenTheory name for conjunction really is Data.Bool./\\ then. All right. On Mon, Jan 10, 2011 at 9:02 PM, Joe Hurd wrote: > Hi Ramana, > >> Hmm... could I ask one more question actually, to be sure? >> You gave the example of the two names A\.b and and A.b. >> Suppose I have an article that defines two different constants with these names. >> Somewhere in the article file there must be lines that instruct the >> virtual machine to push those names onto the stack. >> What exactly would those lines look like? > > The two command lines would be > > "A\.b" > > and > > "A.b" > > Two *different* names pushed onto the stack. > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Mon Jan 10 23:48:29 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Mon, 10 Jan 2011 23:48:29 +0000 Subject: [opentheory-users] article writers Message-ID: How many proof assistants have article writers? I presume at least HOL-light does, since it was used to make the standard library (right?). However I can't find any OpenTheory related code in the HOL-light sources. This could be because I don't know where to look - is it there to be found? Alternatively, there is a logging.ml file in gilith/opentheory/data/hol-light/, which is certainly useful to read, but appears to be for creating articles in the old format where there was still a "call" command. Is the code for writing articles in the new format available for inspection or copying? From Michael.Norrish at nicta.com.au Tue Jan 11 00:12:00 2011 From: Michael.Norrish at nicta.com.au (Michael Norrish) Date: Tue, 11 Jan 2011 11:12:00 +1100 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: Message-ID: <4D2BA050.5070907@nicta.com.au> On 11/01/11 05:18, Joe Hurd wrote: > I recently wrote a paper on the OpenTheory standard library that > contains some details on this: > http://www.gilith.com/research/papers/stdlib.pdf Emulating HOL Light numerals in HOL4 will be a pain. Is there any way we could avoid having to expose numeral representations to each other? I guess HOL4, red-haired step-child that it is, can special case those constants in any articles that it reads, and also do the appropriate inverse thing when writing its own articles. What does ProofPower do for numerals? Presumably this kind of translation will be beyond the capabilities of the meta-datato describe. Michael From joe at gilith.com Tue Jan 11 00:20:58 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 16:20:58 -0800 Subject: [opentheory-users] article writers In-Reply-To: References: Message-ID: Hi Ramana, > How many proof assistants have article writers? So far only HOL Light has a writer. > However I can't find any OpenTheory related code in the HOL-light > sources. This could be because I don't know where to look - is it > there to be found? I have a git repo that adds proof logging to HOL Light, and tracks the official HOL Light svn repo to stay current. You can get my fork here: http://src.gilith.com/hol-light.html Most of the proof logging infrastructure is in fusion.ml and opentheory/logging.ml Cheers, Joe From joe at gilith.com Tue Jan 11 00:30:51 2011 From: joe at gilith.com (Joe Hurd) Date: Mon, 10 Jan 2011 16:30:51 -0800 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: <4D2BA050.5070907@nicta.com.au> References: <4D2BA050.5070907@nicta.com.au> Message-ID: Hi Michael, Yes, numerals are one step beyond a simple renaming of constant names, and seem to be an example where every theorem prover has its own scheme. > I guess HOL4, red-haired step-child that it is, can special case those > constants in any articles that it reads, and also do the appropriate inverse > thing when writing its own articles. I think this is the right strategy, and I even had to do this for HOL Light, which had a NUMERAL tag around numerals and a special zero used inside numerals. I tried to make the OpenTheory numeral scheme the simplest possible: it uses the standard zero from the natural numbers, two bit0 and bit1 functions, and no surrounding tag. > What does ProofPower do for numerals? I don't know the answer to this. Rob Arthan might, and since he isn't on this mailing list I have cc'ed him on this message. > Presumably this kind of translation will be beyond the capabilities of the > meta-datato describe. I had some success automatically detagging HOL Light theorems as I extracted them, but switching numerals sounds a little harder. Cheers, Joe From ramana.kumar at gmail.com Tue Jan 11 09:20:53 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Tue, 11 Jan 2011 09:20:53 +0000 Subject: [opentheory-users] article writers In-Reply-To: References: Message-ID: fatal: http://src.gilith.com/hol-light/info/refs not found: did you run git update-server-info on the server? On Tue, Jan 11, 2011 at 12:20 AM, Joe Hurd wrote: > Hi Ramana, > >> How many proof assistants have article writers? > > So far only HOL Light has a writer. > >> However I can't find any OpenTheory related code in the HOL-light >> sources. This could be because I don't know where to look - is it >> there to be found? > > I have a git repo that adds proof logging to HOL Light, and tracks the > official HOL Light svn repo to stay current. You can get my fork here: > > http://src.gilith.com/hol-light.html > > Most of the proof logging infrastructure is in fusion.ml and > opentheory/logging.ml > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From rda at lemma-one.com Tue Jan 11 17:01:46 2011 From: rda at lemma-one.com (Rob Arthan) Date: Tue, 11 Jan 2011 17:01:46 +0000 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: <4D2BA050.5070907@nicta.com.au> Message-ID: Joe, & opentheory-users, On 11 Jan 2011, at 00:30, Joe Hurd wrote: > Hi Michael, > > .... >> What does ProofPower do for numerals? > > I don't know the answer to this. Rob Arthan might, and since he isn't > on this mailing list I have cc'ed him on this message. > I should be on the list soon if the moderator will have me :-). ProofPower predates the invention of the bit representations used in HOL4 and HOL Light and improves upon the Classic HOL base 1 representation, by treating natural number literals as a special case in the logical kernel. Natural number literals are constants distinguished by having the right type and having names comprising a string of decimal digits. There is a built-in conversion plus_conv which proves all theorems of the form |- m + n = k where m, n and k are natural number literals. Regards, Rob. From joe at gilith.com Tue Jan 11 21:20:46 2011 From: joe at gilith.com (Joe Hurd) Date: Tue, 11 Jan 2011 13:20:46 -0800 Subject: [opentheory-users] article writers In-Reply-To: References: Message-ID: Hi Ramana, Sorry about that: the http access to git wasn't set up properly. I believe I've fixed it now: could you try again? Cheers, Joe On Tue, Jan 11, 2011 at 1:20 AM, Ramana Kumar wrote: > fatal: http://src.gilith.com/hol-light/info/refs not found: did you > run git update-server-info on the server? > > On Tue, Jan 11, 2011 at 12:20 AM, Joe Hurd wrote: >> Hi Ramana, >> >>> How many proof assistants have article writers? >> >> So far only HOL Light has a writer. >> >>> However I can't find any OpenTheory related code in the HOL-light >>> sources. This could be because I don't know where to look - is it >>> there to be found? >> >> I have a git repo that adds proof logging to HOL Light, and tracks the >> official HOL Light svn repo to stay current. You can get my fork here: >> >> http://src.gilith.com/hol-light.html >> >> Most of the proof logging infrastructure is in fusion.ml and >> opentheory/logging.ml >> >> Cheers, >> >> Joe >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Tue Jan 11 21:38:33 2011 From: joe at gilith.com (Joe Hurd) Date: Tue, 11 Jan 2011 13:38:33 -0800 Subject: [opentheory-users] article reader for HOL4 In-Reply-To: References: <4D2BA050.5070907@nicta.com.au> Message-ID: Hi Rob, Welcome to the list! > ProofPower predates the invention of the bit representations used in HOL4 and HOL Light and improves upon the Classic HOL base 1 representation, by treating natural number literals as a special case in the logical kernel. Natural number literals are constants distinguished by having the right type and having names comprising a string of decimal digits. There is a built-in conversion plus_conv which proves all theorems of the form |- m + n = k where m, n and k are natural number literals. It appears that I was correct in my assertion that all the HOL theorem provers use different numeral representations! However, even though ProofPower uses an infinite family of constants together with an extra rule of inference, I don't believe it will be too hard to convert to and from the OpenTheory scheme which defines bit0 and bit1, and uses these constants together with natural number zero to represent numerals. A simple proof procedure can be used to provide a fully-expansive OpenTheory proof of the theorem |- m + n = k where m, n and k are OpenTheory numerals. In the opposite direction the theorems |- bit0 m = m + m and |- bit1 m = bit0 m + 1 should be able to be used in conjunction with plus_conv to post-process theorems imported into ProofPower that contain OpenTheory numerals. Cheers, Joe From ramana.kumar at gmail.com Tue Jan 11 21:58:40 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Tue, 11 Jan 2011 21:58:40 +0000 Subject: [opentheory-users] article writers In-Reply-To: References: Message-ID: On Tue, Jan 11, 2011 at 9:20 PM, Joe Hurd wrote: > Hi Ramana, > > Sorry about that: the http access to git wasn't set up properly. I > believe I've fixed it now: could you try again? thanks - works now. > > Cheers, > > Joe > > On Tue, Jan 11, 2011 at 1:20 AM, Ramana Kumar wrote: >> fatal: http://src.gilith.com/hol-light/info/refs not found: did you >> run git update-server-info on the server? >> >> On Tue, Jan 11, 2011 at 12:20 AM, Joe Hurd wrote: >>> Hi Ramana, >>> >>>> How many proof assistants have article writers? >>> >>> So far only HOL Light has a writer. >>> >>>> However I can't find any OpenTheory related code in the HOL-light >>>> sources. This could be because I don't know where to look - is it >>>> there to be found? >>> >>> I have a git repo that adds proof logging to HOL Light, and tracks the >>> official HOL Light svn repo to stay current. You can get my fork here: >>> >>> http://src.gilith.com/hol-light.html >>> >>> Most of the proof logging infrastructure is in fusion.ml and >>> opentheory/logging.ml >>> >>> Cheers, >>> >>> Joe >>> >>> _______________________________________________ >>> opentheory-users mailing list >>> opentheory-users at gilith.com >>> http://www.gilith.com/mailman/listinfo/opentheory-users >>> >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Tue Jan 11 22:13:56 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Tue, 11 Jan 2011 22:13:56 +0000 Subject: [opentheory-users] mapping names in opentheory Message-ID: On Mon, Jan 10, 2011 at 8:49 PM, Joe Hurd wrote: >But what I would expect is that you would have functions: > > importName : openTheoryName -> holName > > exportName : holName -> openTheoryName > > that you would always use for converting between HOL4 names and > OpenTheory names. I have started adding these functions to HOL4 (the dictionaries are there but not well-populated). But now I am wondering about test/interpretations/hol-light.int in the opentheory source repository. What is the point of this file, and where/how is it used? Is it an alternative method whereby the above functions are unrequired, each proof assistant only ever deals with its own names and reads/writes articles about them, and opentheory takes care of the renaming instead? If so, which method is preferred? From joe at gilith.com Tue Jan 11 22:27:42 2011 From: joe at gilith.com (Joe Hurd) Date: Tue, 11 Jan 2011 14:27:42 -0800 Subject: [opentheory-users] mapping names in opentheory In-Reply-To: References: Message-ID: Hi Ramana, I believe that all system-dependent interface infrastructure belongs in the HOL theorem provers, not in OpenTheory. The hol-light.int file in the opentheory repo is just used for regression testing, and really belongs in the hol-light git repo I recently made available. I should move it. Cheers, Joe On Tue, Jan 11, 2011 at 2:13 PM, Ramana Kumar wrote: > On Mon, Jan 10, 2011 at 8:49 PM, Joe Hurd wrote: >>But what I would expect is that you would have functions: >> >> importName : openTheoryName -> holName >> >> exportName : holName -> openTheoryName >> >> that you would always use for converting between HOL4 names and >> OpenTheory names. > > I have started adding these functions to HOL4 (the dictionaries are > there but not well-populated). > But now I am wondering about test/interpretations/hol-light.int in the > opentheory source repository. > What is the point of this file, and where/how is it used? > Is it an alternative method whereby the above functions are > unrequired, each proof assistant only ever deals with its own names > and reads/writes articles about them, and opentheory takes care of the > renaming instead? > If so, which method is preferred? > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Wed Jan 12 16:17:52 2011 From: joe at gilith.com (Joe Hurd) Date: Wed, 12 Jan 2011 08:17:52 -0800 Subject: [opentheory-users] mapping names in opentheory In-Reply-To: References: Message-ID: Hi Ramana, Further to this, I've moved the hol-light.int file to my instrumented version of HOL Light, and made a new release of opentheory with a little less cruft. Cheers, Joe On Tue, Jan 11, 2011 at 2:27 PM, Joe Hurd wrote: > Hi Ramana, > > I believe that all system-dependent interface infrastructure belongs > in the HOL theorem provers, not in OpenTheory. The hol-light.int file > in the opentheory repo is just used for regression testing, and really > belongs in the hol-light git repo I recently made available. I should > move it. > > Cheers, > > Joe > > On Tue, Jan 11, 2011 at 2:13 PM, Ramana Kumar wrote: >> On Mon, Jan 10, 2011 at 8:49 PM, Joe Hurd wrote: >>>But what I would expect is that you would have functions: >>> >>> importName : openTheoryName -> holName >>> >>> exportName : holName -> openTheoryName >>> >>> that you would always use for converting between HOL4 names and >>> OpenTheory names. >> >> I have started adding these functions to HOL4 (the dictionaries are >> there but not well-populated). >> But now I am wondering about test/interpretations/hol-light.int in the >> opentheory source repository. >> What is the point of this file, and where/how is it used? >> Is it an alternative method whereby the above functions are >> unrequired, each proof assistant only ever deals with its own names >> and reads/writes articles about them, and opentheory takes care of the >> renaming instead? >> If so, which method is preferred? >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > From ramana.kumar at gmail.com Thu Jan 13 23:08:36 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Thu, 13 Jan 2011 23:08:36 +0000 Subject: [opentheory-users] wishlist for the opentheory tool Message-ID: Let me know if any of these are in the works or in fact already present. Also, if there are good reasons to avoid them. List/search available repos (Is a repo identified by a URL?) Search for packages by name Search for packages by term matching on the conclusions of theorems it exports Option to print types in info --summary Option to print arities of type operators in info --summary Machine readable version of info --summary output Option to disable "Show:" tags in info --summary Article file optimization. (Given an article file, write a new one that has the same imports and exports but uses fewer virtual machine instructions; optionally the instructions could be weighted by "difficulty".) Somewhere to store a list like this of desired features (and issues etc.) that can be publicly viewed and edited, i.e. bug tracker. From ramana.kumar at gmail.com Thu Jan 13 23:17:35 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Thu, 13 Jan 2011 23:17:35 +0000 Subject: [opentheory-users] necessity of the primitive inference rules Message-ID: Are the OpenTheory inference rules (virtual machine commands that leave theorems on the stack, apart from axiom) all necessary? More precisely I mean are they any commands for which there are certain imports and exports such that any article file with those imports and exports must include the command, and one such article exists? I presume this is also a question about HOL Light's kernel, since OpenTheory's inference rules are the same... right? From joe at gilith.com Fri Jan 14 18:09:30 2011 From: joe at gilith.com (Joe Hurd) Date: Fri, 14 Jan 2011 10:09:30 -0800 Subject: [opentheory-users] necessity of the primitive inference rules In-Reply-To: References: Message-ID: Hi Ramana, I'm not an expert in these matters, but I believe that John Harrison chose a minimal kernel for HOL Light, so every inference rule is necessary. There is one exception to this, which is that he included the TRANS rule A |- t = u B |- u = v --------------------------- A u B |- t = v in the logical kernel, even though it can be derived from the other rules. The OpenTheory kernel is essentially the same as the HOL Light kernel, except that it does not include a TRANS rule. Instead, the logging code (in logging.ml) looks like | Trans_proof (th1,th2) -> let tm = rator (concl th1) in let () = log_term tm in let () = log_command "refl" in let () = log_thm th2 in let () = log_command "appThm" in let () = log_thm th1 in let () = log_command "eqMp" in () which reduces TRANS to refl, appThm and eqMp. Cheers, Joe On Thu, Jan 13, 2011 at 3:17 PM, Ramana Kumar wrote: > Are the OpenTheory inference rules (virtual machine commands that > leave theorems on the stack, apart from axiom) all necessary? > More precisely I mean are they any commands for which there are > certain imports and exports such that any article file with those > imports and exports must include the command, and one such article > exists? > > I presume this is also a question about HOL Light's kernel, since > OpenTheory's inference rules are the same... right? > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Fri Jan 14 18:16:57 2011 From: joe at gilith.com (Joe Hurd) Date: Fri, 14 Jan 2011 10:16:57 -0800 Subject: [opentheory-users] interesting articles In-Reply-To: References: Message-ID: Hi Ramana, [I'm replying to the OpenTheory mailing list, since I think your question is of general interest.] I am currently working on some example HOL Light theories that I need to support some verified Haskell libraries, the beginnings of which can be found in hol-light/opentheory/examples/ However, I think it will be some time before I export any theories that expand the HOL4 universe. My future plans include packaging up my HOL4 probability theories, which will require the real numbers to be packaged, and then the HOL Light complex numbers would be reachable and interesting to HOL4 users, but that's some way off. However, your idea of building a HOL4 exporter would certainly help with this. Cheers, Joe On Thu, Jan 13, 2011 at 4:42 PM, Ramana Kumar wrote: > Have you exported any articles for things outside the standard > library? Is it easy? (Anything is relatively hard for me since I don't > have ocaml installed, but if it's easy to export any theory once I > have hol-light installed I might consider doing it myself) > > I'm thinking of testing my reader on something HOL4 users would > actually want. (I'm going to test it on more stdlib stuff first though > probably.) > From joe at gilith.com Fri Jan 14 19:00:47 2011 From: joe at gilith.com (Joe Hurd) Date: Fri, 14 Jan 2011 11:00:47 -0800 Subject: [opentheory-users] wishlist for the opentheory tool In-Reply-To: References: Message-ID: Hi Ramana, Thanks for the feature requests: here are my thoughts on them. > List/search available repos (Is a repo identified by a URL?) The repos known to one particular installation of OpenTheory are listed in the ~/.opentheory/config file. It would make sense for the OpenTheory project home page to contain a list of all public repos. > Search for packages by name Good idea: I've been tossing around the idea of an "opentheory search" command for a while. > Search for packages by term matching on the conclusions of theorems it exports Also a good idea, but harder to implement because the local installation only knows this information about the packages that are locally installed. > Option to print types in info --summary > Option to print arities of type operators in info --summary I could certainly add a flag to print this information, but in my experience these annotations make the output a lot less readable. Have you tried mousing over elements in the HTML package summary http://opentheory.gilith.com/opentheory/packages/base-1.0/base-1.0.html The information you ask for should magically pop up when you leave the mouse over an element for while (at least, it does on my Firefox browser). > Machine readable version of info --summary output Good idea: in the future plans. > Option to disable "Show:" tags in info --summary Good idea. > Article file optimization. (Given an article file, write a new one > that has the same imports and exports but uses fewer virtual machine > instructions; optionally the instructions could be weighted by > "difficulty".) The opentheory tool already does this: opentheory info --article -o output.art input.art applies some heuristics (mainly sharing maximization) to compress input.art and writes the result to output.art. > Somewhere to store a list like this of desired features (and issues > etc.) that can be publicly viewed and edited, i.e. bug tracker. This is trickier: I've been avoiding setting up accounts in the OpenTheory project, but allowing people to submit feature requests anonymously would invite spam. For now, I propose using the email list for this purpose: I'll try to fix bugs ASAP, and will maintain a list of feature requests at http://www.gilith.com/software/opentheory/requests.html Cheers, Joe From ramana.kumar at gmail.com Fri Jan 14 20:15:40 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Fri, 14 Jan 2011 20:15:40 +0000 Subject: [opentheory-users] wishlist for the opentheory tool In-Reply-To: References: Message-ID: On Fri, Jan 14, 2011 at 7:00 PM, Joe Hurd wrote: > Hi Ramana, > > Thanks for the feature requests: here are my thoughts on them. > >> List/search available repos (Is a repo identified by a URL?) > > The repos known to one particular installation of OpenTheory are > listed in the ~/.opentheory/config file. It would make sense for the > OpenTheory project home page to contain a list of all public repos. > >> Search for packages by name > > Good idea: I've been tossing around the idea of an "opentheory search" > command for a while. > >> Search for packages by term matching on the conclusions of theorems it exports > > Also a good idea, but harder to implement because the local > installation only knows this information about the packages that are > locally installed. perhaps on the website? package managers usually store enough about packages in various repos to be able to search by title and description... I think terms in the inputs and outputs of theories are at about the description level of theory packages... although I could understand perceiving them as at a level of more detail (since there may well be an English text description for a theory package too) is it hard to implement for locally installed packages? > >> Option to print types in info --summary >> Option to print arities of type operators in info --summary > > I could certainly add a flag to print this information, but in my > experience these annotations make the output a lot less readable. Have > you tried mousing over elements in the HTML package summary > > http://opentheory.gilith.com/opentheory/packages/base-1.0/base-1.0.html > > The information you ask for should magically pop up when you leave the > mouse over an element for while (at least, it does on my Firefox > browser). Yeah the tooltips work - nice. I think I mainly wanted the info for machine reading - for humans the current output is fine (and the html is even better). > >> Machine readable version of info --summary output > > Good idea: in the future plans. > >> Option to disable "Show:" tags in info --summary > > Good idea. > >> Article file optimization. (Given an article file, write a new one >> that has the same imports and exports but uses fewer virtual machine >> instructions; optionally the instructions could be weighted by >> "difficulty".) > > The opentheory tool already does this: > > opentheory info --article -o output.art input.art > > applies some heuristics (mainly sharing maximization) to compress > input.art and writes the result to output.art. Excellent! I guess I should only think about further optimizations when I have some slow examples to play with. > >> Somewhere to store a list like this of desired features (and issues >> etc.) that can be publicly viewed and edited, i.e. bug tracker. > > This is trickier: I've been avoiding setting up accounts in the > OpenTheory project, but allowing people to submit feature requests > anonymously would invite spam. For now, I propose using the email list > for this purpose: I'll try to fix bugs ASAP, and will maintain a list > of feature requests at > > http://www.gilith.com/software/opentheory/requests.html OK great. > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Fri Jan 14 21:11:11 2011 From: joe at gilith.com (Joe Hurd) Date: Fri, 14 Jan 2011 13:11:11 -0800 Subject: [opentheory-users] wishlist for the opentheory tool In-Reply-To: References: Message-ID: Hi Ramana, >>> Search for packages by term matching on the conclusions of theorems it exports >> >> Also a good idea, but harder to implement because the local >> installation only knows this information about the packages that are >> locally installed. > > perhaps on the website? > package managers usually store enough about packages in various repos > to be able to search by title and description... I think terms in the > inputs and outputs of theories are at about the description level of > theory packages... although I could understand perceiving them as at a > level of more detail (since there may well be an English text > description for a theory package too) I think this is the right approach. I wanted to keep the locally stored information to a minimum, so opentheory just locally stores the name and checksum of the available packages on each repo. However, if you want to search packages by description or theorem, then it's reasonable to submit a request to the repo to do this on your behalf. Which reduces the problem to... > is it hard to implement for locally installed packages? At this point I don't know: I should certainly consider this kind of searchability when designing a machine readable format for theory summaries. Cheers, Joe From ramana.kumar at gmail.com Sat Jan 15 09:44:39 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 15 Jan 2011 09:44:39 +0000 Subject: [opentheory-users] type definitions Message-ID: Is there a good reason for the defineTypeOp command to define new constants as well as the new type operator? It's causing me a bit of trouble when trying to write an article writer for HOL4, because HOL4's type definition mechanism doesn't introduce new constants as well. Those constants can be defined after the type is defined (both by HOL4 and by other stack machine commands), although that might require Hilbert choice to be present... actually, if it does require select maybe that's a good reason to do it your way, since the stack machine currently doesn't depend on any constants existing (except =). The HOL4 way of doing a type definition is given a theorem |- P t, to assert |- ?rep. (?x' x''. (rep x' = rep x'') ? (x' = x'')) ? ?x. P x ? ?x'. x = rep x')... so it depends on exists and forall as well. I am starting to see the reasons for the inconvenient defineTypeOp... were they deliberate decisions to avoid those constants? Anyway it seems like to write a HOL4 article writer, one would just need to define some dummy constants every time some HOL4 code wants to define a type operator without providing the names for abs and rep (in order to be able to accurately log a defineTypeOp command); later if they decide to define an abs and reps then there will just be two pairs of constants around doing the same job. From ramana.kumar at gmail.com Sat Jan 15 12:41:24 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 15 Jan 2011 12:41:24 +0000 Subject: [opentheory-users] interesting articles In-Reply-To: References: Message-ID: On Fri, Jan 14, 2011 at 6:16 PM, Joe Hurd wrote: > Hi Ramana, > > [I'm replying to the OpenTheory mailing list, since I think your > question is of general interest.] > > I am currently working on some example HOL Light theories that I need > to support some verified Haskell libraries, the beginnings of which > can be found in hol-light/opentheory/examples/ > > However, I think it will be some time before I export any theories > that expand the HOL4 universe. My future plans include packaging up my > HOL4 probability theories, which will require the real numbers to be > packaged, and then the HOL Light complex numbers would be reachable > and interesting to HOL4 users, but that's some way off. However, your > idea of building a HOL4 exporter would certainly help with this. Indeed how would you package the probability theories without a HOL4 exporter? By porting the script files to HOL-light manually? > > Cheers, > > Joe > > On Thu, Jan 13, 2011 at 4:42 PM, Ramana Kumar wrote: >> Have you exported any articles for things outside the standard >> library? Is it easy? (Anything is relatively hard for me since I don't >> have ocaml installed, but if it's easy to export any theory once I >> have hol-light installed I might consider doing it myself) >> >> I'm thinking of testing my reader on something HOL4 users would >> actually want. (I'm going to test it on more stdlib stuff first though >> probably.) >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Sat Jan 15 13:17:45 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 15 Jan 2011 13:17:45 +0000 Subject: [opentheory-users] type definitions In-Reply-To: References: Message-ID: It occurs to me that it's all right if the stack machine simulating me defines a constant, as long as neither I nor it ever refers to that constant again. Since I won't define the constant, I certainly won't refer to it again, and since I'm writing the article for the stack machine, I will make sure it doesn't refer to it either. Is this reasoning correct? The only problem, then, would be that the article would have these dummy constants among its exports. Can I use OpenTheory's "Unwanted" namespace to effectively take them out of the exported definitions? On Sat, Jan 15, 2011 at 9:44 AM, Ramana Kumar wrote: > Is there a good reason for the defineTypeOp command to define new > constants as well as the new type operator? > > It's causing me a bit of trouble when trying to write an article > writer for HOL4, because HOL4's type definition mechanism doesn't > introduce new constants as well. Those constants can be defined after > the type is defined (both by HOL4 and by other stack machine > commands), although that might require Hilbert choice to be present... > actually, if it does require select maybe that's a good reason to do > it your way, since the stack machine currently doesn't depend on any > constants existing (except =). > > The HOL4 way of doing a type definition is given a theorem |- P t, to > assert |- ?rep. (?x' x''. (rep x' = rep x'') ? (x' = x'')) ? ?x. P x ? > ?x'. x = rep x')... so it depends on exists and forall as well. I am > starting to see the reasons for the inconvenient defineTypeOp... were > they deliberate decisions to avoid those constants? > > Anyway it seems like to write a HOL4 article writer, one would just > need to define some dummy constants every time some HOL4 code wants to > define a type operator without providing the names for abs and rep (in > order to be able to accurately log a defineTypeOp command); later if > they decide to define an abs and reps then there will just be two > pairs of constants around doing the same job. > From joe at gilith.com Sat Jan 15 18:34:30 2011 From: joe at gilith.com (Joe Hurd) Date: Sat, 15 Jan 2011 10:34:30 -0800 Subject: [opentheory-users] interesting articles In-Reply-To: References: Message-ID: Hi Ramana, > Indeed how would you package the probability theories without a HOL4 exporter? > By porting the script files to HOL-light manually? My plan was rather to port my HOL Light exporter to HOL4. I just meant that you building a HOL4 exporter would remove a task from the path towards getting useful theories into OpenTheory format. Cheers, Joe From joe at gilith.com Sat Jan 15 18:46:03 2011 From: joe at gilith.com (Joe Hurd) Date: Sat, 15 Jan 2011 10:46:03 -0800 Subject: [opentheory-users] type definitions In-Reply-To: References: Message-ID: Hi Ramana, > It occurs to me that it's all right if the stack machine simulating me > defines a constant, as long as neither I nor it ever refers to that > constant again. > Since I won't define the constant, I certainly won't refer to it > again, and since I'm writing the article for the stack machine, I will > make sure it doesn't refer to it either. > Is this reasoning correct? Here's what I see happening: 1. Emit an OpenTheory defineTypeOp command to define the type (plus two constants abs and rep). 2. Use the resulting OpenTheory theorems, plus the abs and rep constants, plus some Boolean theorems, to simulate the proof in OpenTheory of the canonical HOL4 output: >> |- ?rep. (?x' x''. (rep x' = rep x'') ? (x' = x'')) ? ?x. P x ? >> ?x'. x = rep x') 3. Now at this point you can proceed, and you'll never need to refer to the abs and rep constants again. > The only problem, then, would be that the article would have these > dummy constants among its exports. The list of exported constants is precisely the constants appearing in exported theorems, so these kind of abs and rep constants won't appear. > Can I use OpenTheory's "Unwanted" namespace to effectively take them > out of the exported definitions? I would rather prefer that you named them ty.abs and ty.rep, where ty is the name of the type that you're defining. That should avoid any name clash, and make it clear that these are internal constants for use in the proof but not for export. The Unwanted namespace is used as a directive to the opentheory tool that it should remove these constants and type operators from the theory, so that they do appear even in the proof. For example, it is used for removing the HOL Light "NUMERAL" tag that gets wrapped around numerals. These abs and rep constants are necessarily used in the proof, so shouldn't sit in the Unwanted namespace. Cheers, Joe From ramana.kumar at gmail.com Sat Jan 15 19:59:33 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 15 Jan 2011 19:59:33 +0000 Subject: [opentheory-users] article format wording about constants Message-ID: What does the phrase "with definition ..." mean in the article format spec? In my opinion it doesn't add anything except potential confusion. It seems like your idea of what a constant is is something with a name and a definition. However the definition bit (filling in the "..." above) is never particularly illuminating: "null" or "def(t)" or "def(phi,A)" etc. My idea of a constant is something that has a name and a type, so the type argument to the constTerm command is just a checksum to me, but I can probably live with the idea that constants need types before they become real terms. However, notice the asymmetry: const takes 1 argument, constTerm takes 2, but var takes 2 arguments and varTerm takes 1. Surely constants should act more like variables? Or even have their types entirely determined by their names? The only ways to get constants apart from the const command (defineConst and defineTypeOp) are ways that would fix their types. Also, it's not clear whether a "new constant" with the same name as a previously defined constant is allowed. I presume so. From joe at gilith.com Sat Jan 15 21:13:08 2011 From: joe at gilith.com (Joe Hurd) Date: Sat, 15 Jan 2011 13:13:08 -0800 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: Hi Ramana, > What does the phrase "with definition ..." mean in the article format spec? > In my opinion it doesn't add anything except potential confusion. I agree that the "with definition ..." language is more confusing than helpful, and I've removed it from the article format spec. > However, notice the asymmetry: const takes 1 argument, constTerm takes > 2, but var takes 2 arguments and varTerm takes 1. Surely constants > should act more like variables? This asymmetry is deliberate, and reflects a fundamental difference of constants and variables. Constants are determined just by their name, but variables are determined by their name and type. This is illustrated by the theorems |- !(v : 'a list) (v : bool list). P (v : 'a list) (v : bool list) |- P (c : 'a list) (c : bool list) Applying the type instantiation ('a |-> bool) to both results in |- !(v : bool list) (v' : bool list). P (v : bool list) (v' : bool list) |- P (c : bool list) (c : bool list) where the two constants have been identified, but the two variables have been kept separate. > Also, it's not clear whether a "new constant" with the same name as a > previously defined constant is allowed. I presume so. This is left to the system, which must be careful to disallow define `c = T` define `c = F` prove `T = F` I believe all of the HOL theorem provers maintain a symbol table of constants, and will not allow redefinitions with the same name. The logical kernel of the opentheory tool stores the definition with the constant, so will happily allow redefinitions with the same name (because the two "c" constants above will be treated as different constants). Cheers, Joe From ramana.kumar at gmail.com Sat Jan 15 21:41:21 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 15 Jan 2011 21:41:21 +0000 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: On Sat, Jan 15, 2011 at 9:13 PM, Joe Hurd wrote: > Hi Ramana, > >> What does the phrase "with definition ..." mean in the article format spec? >> In my opinion it doesn't add anything except potential confusion. > > I agree that the "with definition ..." language is more confusing than > helpful, and I've removed it from the article format spec. > >> However, notice the asymmetry: const takes 1 argument, constTerm takes >> 2, but var takes 2 arguments and varTerm takes 1. Surely constants >> should act more like variables? > > This asymmetry is deliberate, and reflects a fundamental difference of > constants and variables. Constants are determined just by their name, > but variables are determined by their name and type. This is > illustrated by the theorems > > |- !(v : 'a list) (v : bool list). P (v : 'a list) (v : bool list) > > |- P (c : 'a list) (c : bool list) > > Applying the type instantiation ('a |-> bool) to both results in > > |- !(v : bool list) (v' : bool list). P (v : bool list) (v' : bool list) > > |- P (c : bool list) (c : bool list) > > where the two constants have been identified, but the two variables > have been kept separate. So why does constTerm take 2 arguments instead of just 1? Is it just to allow you to instantiate type variables that might be in the constant on the stack? > >> Also, it's not clear whether a "new constant" with the same name as a >> previously defined constant is allowed. I presume so. > > This is left to the system, which must be careful to disallow > > define `c = T` > define `c = F` > prove `T = F` > > I believe all of the HOL theorem provers maintain a symbol table of > constants, and will not allow redefinitions with the same name. The > logical kernel of the opentheory tool stores the definition with the > constant, so will happily allow redefinitions with the same name > (because the two "c" constants above will be treated as different > constants). HOL4 allows redefinitions with the same name and marks the old constant as "old"; only constants that aren't so marked can appear in any saved theory segment, but while developing a segment it enables one to redefine the same constant many times. You wouldn't be able to prove `T = F` as above, though, because the theorem equating `c = T` would be turned into `OLDc = T` when `c` is redefined, effectively making the old one a different constant. This is similar to opentheory, except the marks don't know anything about the definition of the constant, they're essentially just timestamps. So I think if while recording an OpenTheory article from HOL4 if you redefine a constant, the right thing will happen: both systems will treat the new constant as different from the old, even though it has the same name. > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From ramana.kumar at gmail.com Sat Jan 15 21:50:46 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 15 Jan 2011 21:50:46 +0000 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: On Sat, Jan 15, 2011 at 9:41 PM, Ramana Kumar wrote: > On Sat, Jan 15, 2011 at 9:13 PM, Joe Hurd wrote: >> Hi Ramana, >> >>> What does the phrase "with definition ..." mean in the article format spec? >>> In my opinion it doesn't add anything except potential confusion. >> >> I agree that the "with definition ..." language is more confusing than >> helpful, and I've removed it from the article format spec. >> >>> However, notice the asymmetry: const takes 1 argument, constTerm takes >>> 2, but var takes 2 arguments and varTerm takes 1. Surely constants >>> should act more like variables? >> >> This asymmetry is deliberate, and reflects a fundamental difference of >> constants and variables. Constants are determined just by their name, >> but variables are determined by their name and type. This is >> illustrated by the theorems >> >> |- !(v : 'a list) (v : bool list). P (v : 'a list) (v : bool list) >> >> |- P (c : 'a list) (c : bool list) >> >> Applying the type instantiation ('a |-> bool) to both results in >> >> |- !(v : bool list) (v' : bool list). P (v : bool list) (v' : bool list) >> >> |- P (c : bool list) (c : bool list) >> >> where the two constants have been identified, but the two variables >> have been kept separate. This is not true in HOL4. The following does not raise Bind: val P = mk_var("P",``:'a list -> bool list -> bool``) val va = mk_var("v",``:'a list``) val vb = mk_var("v",``:bool list``) val Pvv = list_mk_comb(P,[va,vb]) val Pvv = mk_thm([],Pvv) val false = let val (_,[va,vb]) = strip_comb(concl Pvv) in va = vb end val Pvv' = INST_TYPE [alpha|->bool] Pvv val true = let val (_,[va,vb]) = strip_comb(concl Pvv') in va = vb end > > So why does constTerm take 2 arguments instead of just 1? > Is it just to allow you to instantiate type variables that might be in > the constant on the stack? > >> >>> Also, it's not clear whether a "new constant" with the same name as a >>> previously defined constant is allowed. I presume so. >> >> This is left to the system, which must be careful to disallow >> >> define `c = T` >> define `c = F` >> prove `T = F` >> >> I believe all of the HOL theorem provers maintain a symbol table of >> constants, and will not allow redefinitions with the same name. The >> logical kernel of the opentheory tool stores the definition with the >> constant, so will happily allow redefinitions with the same name >> (because the two "c" constants above will be treated as different >> constants). > > HOL4 allows redefinitions with the same name and marks the old > constant as "old"; only constants that aren't so marked can appear in > any saved theory segment, but while developing a segment it enables > one to redefine the same constant many times. You wouldn't be able to > prove `T = F` as above, though, because the theorem equating `c = T` > would be turned into `OLDc = T` when `c` is redefined, effectively > making the old one a different constant. This is similar to > opentheory, except the marks don't know anything about the definition > of the constant, they're essentially just timestamps. > > So I think if while recording an OpenTheory article from HOL4 if you > redefine a constant, the right thing will happen: both systems will > treat the new constant as different from the old, even though it has > the same name. > >> >> Cheers, >> >> Joe >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > From ramana.kumar at gmail.com Sat Jan 15 21:56:58 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 15 Jan 2011 21:56:58 +0000 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: Actually, I see this phrase in the HOL4 documentation for INST_TYPE: "Variables will be renamed if necessary to prevent distinct variables becoming identical after the instantiation." So it would seem there is a bug in whatever version of HOL4 I happen to have built at the moment... (which may be one whose kernel I was playing around with... will continue this thread on a HOL4 list if necessary) At least the documentation of INST_TYPE matches your description of a fundamental difference between constants and variables :) On Sat, Jan 15, 2011 at 9:50 PM, Ramana Kumar wrote: > On Sat, Jan 15, 2011 at 9:41 PM, Ramana Kumar wrote: >> On Sat, Jan 15, 2011 at 9:13 PM, Joe Hurd wrote: >>> Hi Ramana, >>> >>>> What does the phrase "with definition ..." mean in the article format spec? >>>> In my opinion it doesn't add anything except potential confusion. >>> >>> I agree that the "with definition ..." language is more confusing than >>> helpful, and I've removed it from the article format spec. >>> >>>> However, notice the asymmetry: const takes 1 argument, constTerm takes >>>> 2, but var takes 2 arguments and varTerm takes 1. Surely constants >>>> should act more like variables? >>> >>> This asymmetry is deliberate, and reflects a fundamental difference of >>> constants and variables. Constants are determined just by their name, >>> but variables are determined by their name and type. This is >>> illustrated by the theorems >>> >>> |- !(v : 'a list) (v : bool list). P (v : 'a list) (v : bool list) >>> >>> |- P (c : 'a list) (c : bool list) >>> >>> Applying the type instantiation ('a |-> bool) to both results in >>> >>> |- !(v : bool list) (v' : bool list). P (v : bool list) (v' : bool list) >>> >>> |- P (c : bool list) (c : bool list) >>> >>> where the two constants have been identified, but the two variables >>> have been kept separate. > > This is not true in HOL4. > The following does not raise Bind: > > val P = mk_var("P",``:'a list -> bool list -> bool``) > val va = mk_var("v",``:'a list``) > val vb = mk_var("v",``:bool list``) > val Pvv = list_mk_comb(P,[va,vb]) > val Pvv = mk_thm([],Pvv) > val false = let > ?val (_,[va,vb]) = strip_comb(concl Pvv) > in va = vb end > val Pvv' = INST_TYPE [alpha|->bool] Pvv > val true = let > ?val (_,[va,vb]) = strip_comb(concl Pvv') > in va = vb end > > >> >> So why does constTerm take 2 arguments instead of just 1? >> Is it just to allow you to instantiate type variables that might be in >> the constant on the stack? >> >>> >>>> Also, it's not clear whether a "new constant" with the same name as a >>>> previously defined constant is allowed. I presume so. >>> >>> This is left to the system, which must be careful to disallow >>> >>> define `c = T` >>> define `c = F` >>> prove `T = F` >>> >>> I believe all of the HOL theorem provers maintain a symbol table of >>> constants, and will not allow redefinitions with the same name. The >>> logical kernel of the opentheory tool stores the definition with the >>> constant, so will happily allow redefinitions with the same name >>> (because the two "c" constants above will be treated as different >>> constants). >> >> HOL4 allows redefinitions with the same name and marks the old >> constant as "old"; only constants that aren't so marked can appear in >> any saved theory segment, but while developing a segment it enables >> one to redefine the same constant many times. You wouldn't be able to >> prove `T = F` as above, though, because the theorem equating `c = T` >> would be turned into `OLDc = T` when `c` is redefined, effectively >> making the old one a different constant. This is similar to >> opentheory, except the marks don't know anything about the definition >> of the constant, they're essentially just timestamps. >> >> So I think if while recording an OpenTheory article from HOL4 if you >> redefine a constant, the right thing will happen: both systems will >> treat the new constant as different from the old, even though it has >> the same name. >> >>> >>> Cheers, >>> >>> Joe >>> >>> _______________________________________________ >>> opentheory-users mailing list >>> opentheory-users at gilith.com >>> http://www.gilith.com/mailman/listinfo/opentheory-users >>> >> > From ramana.kumar at gmail.com Sat Jan 15 23:10:04 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 15 Jan 2011 23:10:04 +0000 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: Argh... the HOL4 Logic manual has this instead: "After the instantiation, variables free in the input can not become bound, but distinct free variables in the input may become identified." I don't know what to believe any more. On Sat, Jan 15, 2011 at 9:56 PM, Ramana Kumar wrote: > Actually, I see this phrase in the HOL4 documentation for INST_TYPE: > > "Variables will be renamed if necessary to prevent distinct variables > becoming identical after the instantiation." > > So it would seem there is a bug in whatever version of HOL4 I happen > to have built at the moment... (which may be one whose kernel I was > playing around with... will continue this thread on a HOL4 list if > necessary) > > At least the documentation of INST_TYPE matches your description of a > fundamental difference between constants and variables :) > > > On Sat, Jan 15, 2011 at 9:50 PM, Ramana Kumar wrote: >> On Sat, Jan 15, 2011 at 9:41 PM, Ramana Kumar wrote: >>> On Sat, Jan 15, 2011 at 9:13 PM, Joe Hurd wrote: >>>> Hi Ramana, >>>> >>>>> What does the phrase "with definition ..." mean in the article format spec? >>>>> In my opinion it doesn't add anything except potential confusion. >>>> >>>> I agree that the "with definition ..." language is more confusing than >>>> helpful, and I've removed it from the article format spec. >>>> >>>>> However, notice the asymmetry: const takes 1 argument, constTerm takes >>>>> 2, but var takes 2 arguments and varTerm takes 1. Surely constants >>>>> should act more like variables? >>>> >>>> This asymmetry is deliberate, and reflects a fundamental difference of >>>> constants and variables. Constants are determined just by their name, >>>> but variables are determined by their name and type. This is >>>> illustrated by the theorems >>>> >>>> |- !(v : 'a list) (v : bool list). P (v : 'a list) (v : bool list) >>>> >>>> |- P (c : 'a list) (c : bool list) >>>> >>>> Applying the type instantiation ('a |-> bool) to both results in >>>> >>>> |- !(v : bool list) (v' : bool list). P (v : bool list) (v' : bool list) >>>> >>>> |- P (c : bool list) (c : bool list) >>>> >>>> where the two constants have been identified, but the two variables >>>> have been kept separate. >> >> This is not true in HOL4. >> The following does not raise Bind: >> >> val P = mk_var("P",``:'a list -> bool list -> bool``) >> val va = mk_var("v",``:'a list``) >> val vb = mk_var("v",``:bool list``) >> val Pvv = list_mk_comb(P,[va,vb]) >> val Pvv = mk_thm([],Pvv) >> val false = let >> ?val (_,[va,vb]) = strip_comb(concl Pvv) >> in va = vb end >> val Pvv' = INST_TYPE [alpha|->bool] Pvv >> val true = let >> ?val (_,[va,vb]) = strip_comb(concl Pvv') >> in va = vb end >> >> >>> >>> So why does constTerm take 2 arguments instead of just 1? >>> Is it just to allow you to instantiate type variables that might be in >>> the constant on the stack? >>> >>>> >>>>> Also, it's not clear whether a "new constant" with the same name as a >>>>> previously defined constant is allowed. I presume so. >>>> >>>> This is left to the system, which must be careful to disallow >>>> >>>> define `c = T` >>>> define `c = F` >>>> prove `T = F` >>>> >>>> I believe all of the HOL theorem provers maintain a symbol table of >>>> constants, and will not allow redefinitions with the same name. The >>>> logical kernel of the opentheory tool stores the definition with the >>>> constant, so will happily allow redefinitions with the same name >>>> (because the two "c" constants above will be treated as different >>>> constants). >>> >>> HOL4 allows redefinitions with the same name and marks the old >>> constant as "old"; only constants that aren't so marked can appear in >>> any saved theory segment, but while developing a segment it enables >>> one to redefine the same constant many times. You wouldn't be able to >>> prove `T = F` as above, though, because the theorem equating `c = T` >>> would be turned into `OLDc = T` when `c` is redefined, effectively >>> making the old one a different constant. This is similar to >>> opentheory, except the marks don't know anything about the definition >>> of the constant, they're essentially just timestamps. >>> >>> So I think if while recording an OpenTheory article from HOL4 if you >>> redefine a constant, the right thing will happen: both systems will >>> treat the new constant as different from the old, even though it has >>> the same name. >>> >>>> >>>> Cheers, >>>> >>>> Joe >>>> >>>> _______________________________________________ >>>> opentheory-users mailing list >>>> opentheory-users at gilith.com >>>> http://www.gilith.com/mailman/listinfo/opentheory-users >>>> >>> >> > From joe at gilith.com Sat Jan 15 23:12:56 2011 From: joe at gilith.com (Joe Hurd) Date: Sat, 15 Jan 2011 15:12:56 -0800 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: Hi Ramana, > So why does constTerm take 2 arguments instead of just 1? > Is it just to allow you to instantiate type variables that might be in > the constant on the stack? Since constants are solely determined by name (and do not contain any type information), you also have to provide a type argument to turn a constant into a term. Cheers, Joe From ramana.kumar at gmail.com Sat Jan 15 23:16:12 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 15 Jan 2011 23:16:12 +0000 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: On Sat, Jan 15, 2011 at 11:12 PM, Joe Hurd wrote: > Hi Ramana, > >> So why does constTerm take 2 arguments instead of just 1? >> Is it just to allow you to instantiate type variables that might be in >> the constant on the stack? > > Since constants are solely determined by name (and do not contain any > type information), you also have to provide a type argument to turn a > constant into a term. This confuses me... Are you saying it's possible to have two different constant terms where the constants have the same name but different types, where one of the types is not just an instance of the other? > > Cheers, > > Joe > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Sat Jan 15 23:17:38 2011 From: joe at gilith.com (Joe Hurd) Date: Sat, 15 Jan 2011 15:17:38 -0800 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: Hi Ramana, The example I gave make deliberate use of the universal quantifiers to illustrate my point about variables being determined by both name and type. As you found out, without any binders HOL4 does indeed identify the variables, but this can be seen as a 'forced additional specialization': it is always sound to identify free variables in a theorem but a logical weakening may occur as a result. Cheers, Joe On Sat, Jan 15, 2011 at 3:10 PM, Ramana Kumar wrote: > Argh... the HOL4 Logic manual has this instead: > > "After the instantiation, variables free in the input can not become bound, but > ?distinct free variables in the input may become identified." > > I don't know what to believe any more. > > On Sat, Jan 15, 2011 at 9:56 PM, Ramana Kumar wrote: >> Actually, I see this phrase in the HOL4 documentation for INST_TYPE: >> >> "Variables will be renamed if necessary to prevent distinct variables >> becoming identical after the instantiation." >> >> So it would seem there is a bug in whatever version of HOL4 I happen >> to have built at the moment... (which may be one whose kernel I was >> playing around with... will continue this thread on a HOL4 list if >> necessary) >> >> At least the documentation of INST_TYPE matches your description of a >> fundamental difference between constants and variables :) >> >> >> On Sat, Jan 15, 2011 at 9:50 PM, Ramana Kumar wrote: >>> On Sat, Jan 15, 2011 at 9:41 PM, Ramana Kumar wrote: >>>> On Sat, Jan 15, 2011 at 9:13 PM, Joe Hurd wrote: >>>>> Hi Ramana, >>>>> >>>>>> What does the phrase "with definition ..." mean in the article format spec? >>>>>> In my opinion it doesn't add anything except potential confusion. >>>>> >>>>> I agree that the "with definition ..." language is more confusing than >>>>> helpful, and I've removed it from the article format spec. >>>>> >>>>>> However, notice the asymmetry: const takes 1 argument, constTerm takes >>>>>> 2, but var takes 2 arguments and varTerm takes 1. Surely constants >>>>>> should act more like variables? >>>>> >>>>> This asymmetry is deliberate, and reflects a fundamental difference of >>>>> constants and variables. Constants are determined just by their name, >>>>> but variables are determined by their name and type. This is >>>>> illustrated by the theorems >>>>> >>>>> |- !(v : 'a list) (v : bool list). P (v : 'a list) (v : bool list) >>>>> >>>>> |- P (c : 'a list) (c : bool list) >>>>> >>>>> Applying the type instantiation ('a |-> bool) to both results in >>>>> >>>>> |- !(v : bool list) (v' : bool list). P (v : bool list) (v' : bool list) >>>>> >>>>> |- P (c : bool list) (c : bool list) >>>>> >>>>> where the two constants have been identified, but the two variables >>>>> have been kept separate. >>> >>> This is not true in HOL4. >>> The following does not raise Bind: >>> >>> val P = mk_var("P",``:'a list -> bool list -> bool``) >>> val va = mk_var("v",``:'a list``) >>> val vb = mk_var("v",``:bool list``) >>> val Pvv = list_mk_comb(P,[va,vb]) >>> val Pvv = mk_thm([],Pvv) >>> val false = let >>> ?val (_,[va,vb]) = strip_comb(concl Pvv) >>> in va = vb end >>> val Pvv' = INST_TYPE [alpha|->bool] Pvv >>> val true = let >>> ?val (_,[va,vb]) = strip_comb(concl Pvv') >>> in va = vb end >>> >>> >>>> >>>> So why does constTerm take 2 arguments instead of just 1? >>>> Is it just to allow you to instantiate type variables that might be in >>>> the constant on the stack? >>>> >>>>> >>>>>> Also, it's not clear whether a "new constant" with the same name as a >>>>>> previously defined constant is allowed. I presume so. >>>>> >>>>> This is left to the system, which must be careful to disallow >>>>> >>>>> define `c = T` >>>>> define `c = F` >>>>> prove `T = F` >>>>> >>>>> I believe all of the HOL theorem provers maintain a symbol table of >>>>> constants, and will not allow redefinitions with the same name. The >>>>> logical kernel of the opentheory tool stores the definition with the >>>>> constant, so will happily allow redefinitions with the same name >>>>> (because the two "c" constants above will be treated as different >>>>> constants). >>>> >>>> HOL4 allows redefinitions with the same name and marks the old >>>> constant as "old"; only constants that aren't so marked can appear in >>>> any saved theory segment, but while developing a segment it enables >>>> one to redefine the same constant many times. You wouldn't be able to >>>> prove `T = F` as above, though, because the theorem equating `c = T` >>>> would be turned into `OLDc = T` when `c` is redefined, effectively >>>> making the old one a different constant. This is similar to >>>> opentheory, except the marks don't know anything about the definition >>>> of the constant, they're essentially just timestamps. >>>> >>>> So I think if while recording an OpenTheory article from HOL4 if you >>>> redefine a constant, the right thing will happen: both systems will >>>> treat the new constant as different from the old, even though it has >>>> the same name. >>>> >>>>> >>>>> Cheers, >>>>> >>>>> Joe >>>>> >>>>> _______________________________________________ >>>>> opentheory-users mailing list >>>>> opentheory-users at gilith.com >>>>> http://www.gilith.com/mailman/listinfo/opentheory-users >>>>> >>>> >>> >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Sat Jan 15 23:23:14 2011 From: joe at gilith.com (Joe Hurd) Date: Sat, 15 Jan 2011 15:23:14 -0800 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: Hi Ramana, > This confuses me... Are you saying it's possible to have two different constant > terms where the constants have the same name but different types, where one of > the types is not just an instance of the other? A trivial example of this is [] : bool list and [] : num list If these were input constants, the processing tool would never know that they were both instances of a more general [] : 'a list defined in another theory. With defined constants this should never be the case (though theoretically a system could permit same-name constants at disjoint types and remain sound - this was the topic of a long discussion on the HOL4 mailing list some years back). Cheers, Joe From ramana.kumar at gmail.com Sat Jan 15 23:30:33 2011 From: ramana.kumar at gmail.com (Ramana Kumar) Date: Sat, 15 Jan 2011 23:30:33 +0000 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: On Sat, Jan 15, 2011 at 11:17 PM, Joe Hurd wrote: > Hi Ramana, > > The example I gave make deliberate use of the universal quantifiers to > illustrate my point about variables being determined by both name and > type. As you found out, without any binders HOL4 does indeed identify > the variables, but this can be seen as a 'forced additional > specialization': it is always sound to identify free variables in a > theorem but a logical weakening may occur as a result. Does OpenTheory's subst command also do renaming of bound variables where necessary? It might be nice to document that; your call though. I was about to say I want to know how the new names are to be computed, but I realize that since they are bound, it doesn't matter. > > Cheers, > > Joe > > On Sat, Jan 15, 2011 at 3:10 PM, Ramana Kumar wrote: >> Argh... the HOL4 Logic manual has this instead: >> >> "After the instantiation, variables free in the input can not become bound, but >> ?distinct free variables in the input may become identified." >> >> I don't know what to believe any more. >> >> On Sat, Jan 15, 2011 at 9:56 PM, Ramana Kumar wrote: >>> Actually, I see this phrase in the HOL4 documentation for INST_TYPE: >>> >>> "Variables will be renamed if necessary to prevent distinct variables >>> becoming identical after the instantiation." >>> >>> So it would seem there is a bug in whatever version of HOL4 I happen >>> to have built at the moment... (which may be one whose kernel I was >>> playing around with... will continue this thread on a HOL4 list if >>> necessary) >>> >>> At least the documentation of INST_TYPE matches your description of a >>> fundamental difference between constants and variables :) >>> >>> >>> On Sat, Jan 15, 2011 at 9:50 PM, Ramana Kumar wrote: >>>> On Sat, Jan 15, 2011 at 9:41 PM, Ramana Kumar wrote: >>>>> On Sat, Jan 15, 2011 at 9:13 PM, Joe Hurd wrote: >>>>>> Hi Ramana, >>>>>> >>>>>>> What does the phrase "with definition ..." mean in the article format spec? >>>>>>> In my opinion it doesn't add anything except potential confusion. >>>>>> >>>>>> I agree that the "with definition ..." language is more confusing than >>>>>> helpful, and I've removed it from the article format spec. >>>>>> >>>>>>> However, notice the asymmetry: const takes 1 argument, constTerm takes >>>>>>> 2, but var takes 2 arguments and varTerm takes 1. Surely constants >>>>>>> should act more like variables? >>>>>> >>>>>> This asymmetry is deliberate, and reflects a fundamental difference of >>>>>> constants and variables. Constants are determined just by their name, >>>>>> but variables are determined by their name and type. This is >>>>>> illustrated by the theorems >>>>>> >>>>>> |- !(v : 'a list) (v : bool list). P (v : 'a list) (v : bool list) >>>>>> >>>>>> |- P (c : 'a list) (c : bool list) >>>>>> >>>>>> Applying the type instantiation ('a |-> bool) to both results in >>>>>> >>>>>> |- !(v : bool list) (v' : bool list). P (v : bool list) (v' : bool list) >>>>>> >>>>>> |- P (c : bool list) (c : bool list) >>>>>> >>>>>> where the two constants have been identified, but the two variables >>>>>> have been kept separate. >>>> >>>> This is not true in HOL4. >>>> The following does not raise Bind: >>>> >>>> val P = mk_var("P",``:'a list -> bool list -> bool``) >>>> val va = mk_var("v",``:'a list``) >>>> val vb = mk_var("v",``:bool list``) >>>> val Pvv = list_mk_comb(P,[va,vb]) >>>> val Pvv = mk_thm([],Pvv) >>>> val false = let >>>> ?val (_,[va,vb]) = strip_comb(concl Pvv) >>>> in va = vb end >>>> val Pvv' = INST_TYPE [alpha|->bool] Pvv >>>> val true = let >>>> ?val (_,[va,vb]) = strip_comb(concl Pvv') >>>> in va = vb end >>>> >>>> >>>>> >>>>> So why does constTerm take 2 arguments instead of just 1? >>>>> Is it just to allow you to instantiate type variables that might be in >>>>> the constant on the stack? >>>>> >>>>>> >>>>>>> Also, it's not clear whether a "new constant" with the same name as a >>>>>>> previously defined constant is allowed. I presume so. >>>>>> >>>>>> This is left to the system, which must be careful to disallow >>>>>> >>>>>> define `c = T` >>>>>> define `c = F` >>>>>> prove `T = F` >>>>>> >>>>>> I believe all of the HOL theorem provers maintain a symbol table of >>>>>> constants, and will not allow redefinitions with the same name. The >>>>>> logical kernel of the opentheory tool stores the definition with the >>>>>> constant, so will happily allow redefinitions with the same name >>>>>> (because the two "c" constants above will be treated as different >>>>>> constants). >>>>> >>>>> HOL4 allows redefinitions with the same name and marks the old >>>>> constant as "old"; only constants that aren't so marked can appear in >>>>> any saved theory segment, but while developing a segment it enables >>>>> one to redefine the same constant many times. You wouldn't be able to >>>>> prove `T = F` as above, though, because the theorem equating `c = T` >>>>> would be turned into `OLDc = T` when `c` is redefined, effectively >>>>> making the old one a different constant. This is similar to >>>>> opentheory, except the marks don't know anything about the definition >>>>> of the constant, they're essentially just timestamps. >>>>> >>>>> So I think if while recording an OpenTheory article from HOL4 if you >>>>> redefine a constant, the right thing will happen: both systems will >>>>> treat the new constant as different from the old, even though it has >>>>> the same name. >>>>> >>>>>> >>>>>> Cheers, >>>>>> >>>>>> Joe >>>>>> >>>>>> _______________________________________________ >>>>>> opentheory-users mailing list >>>>>> opentheory-users at gilith.com >>>>>> http://www.gilith.com/mailman/listinfo/opentheory-users >>>>>> >>>>> >>>> >>> >> >> _______________________________________________ >> opentheory-users mailing list >> opentheory-users at gilith.com >> http://www.gilith.com/mailman/listinfo/opentheory-users >> > > _______________________________________________ > opentheory-users mailing list > opentheory-users at gilith.com > http://www.gilith.com/mailman/listinfo/opentheory-users > From joe at gilith.com Sat Jan 15 23:38:42 2011 From: joe at gilith.com (Joe Hurd) Date: Sat, 15 Jan 2011 15:38:42 -0800 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: Hi Ramana, > Does OpenTheory's subst command also do renaming of bound variables > where necessary? > It might be nice to document that; your call though. Excellent suggestion - I've added another note to the documentation of the "subst" command. > I was about to say I want to know how the new names are to be > computed, but I realize that since they are bound, it doesn't matter. Indeed, one of the design goals of the article format is that a system reading an article is free to rename bound variables as it pleases. Cheers, Joe From rda at lemma-one.com Sun Jan 16 12:52:41 2011 From: rda at lemma-one.com (Rob Arthan) Date: Sun, 16 Jan 2011 12:52:41 +0000 Subject: [opentheory-users] article format wording about constants In-Reply-To: References: Message-ID: Ramana, Joe, > On 15 Jan 2011, at 21:50, Ramana Kumar wrote: > >> On Sat, Jan 15, 2011 at 9:41 PM, Ramana Kumar wrote: >>> On Sat, Jan 15, 2011 at 9:13 PM, Joe Hurd wrote: >>>> Hi Ramana, >>>> >>> ... >>> Applying the type instantiation ('a |-> bool) to both results in >>> >>> |- !(v : bool list) (v' : bool list). P (v : bool list) (v' : bool list) >>> >>> |- P (c : bool list) (c : bool list) >>> >>> where the two constants have been identified, but the two variables >>> have been kept separate. > > This is not true in HOL4. ... And then: On 15 Jan 2011, at 23:17, Joe Hurd wrote: > Hi Ramana, > > The example I gave make deliberate use of the universal quantifiers to > illustrate my point about variables being determined by both name and > type. As you found out, without any binders HOL4 does indeed identify > the variables, but this can be seen as a 'forced additional > specialization': it is always sound to identify free variables in a > theorem but a logical weakening may occur as a result. Yes: ProofPower's type instantiation rule soundly (although perhaps confusingly) will rename one of the variables in Joe's example. However, there are cases where renaming bound variables is logically necessary. E.g., the following is a theorem because the term beta-reduces to !y:'a.1 = 1: |- !y:'a. (\(x:num)(x:'a). x = 1) 1 y Instantiating 'a to num without renaming would result in a term that beta-reduces to !y:num.y = y and that's false. This has been an unsoundness bug in several implementations of the logic, but I believe they are all fixed now. Regards, Rob.