History log of /seL4-l4v-10.1.1/HOL4/src/parse/Preterm.sml
Revision Date Author Comments
# 3e264ca9 05-Jun-2018 Michael Norrish <Michael.Norrish@nicta.com.au>

Don't report tyvar guesses when warning of actual typecheck errors

Also check for "atomic" preterms (a question that only comes up
generating the error message) without converting to full-blown terms
first.


# bd27d877 27-Sep-2017 Michael Norrish <Michael.Norrish@nicta.com.au>

Remove some early code assuming term is an equality type


# 7493f6af 25-Jul-2017 Michael Norrish <Michael.Norrish@nicta.com.au>

Fix bug in free-var calculation for preterms (with test)


# 7f2c629e 08-Jan-2017 Michael Norrish <Michael.Norrish@nicta.com.au>

Reorganise flow of overloading resolution

This should let more specific errors escape the process. Now, the test
case in the selftest lets a (located) error about the impossible
interaction between < and T escape to the user. Previously, 3 + 4 <
T (with < and + overloaded to integer and number possibilities) was
just generating the "no resolution of overloads possible" message
without a helpful location.


# 0035e14e 08-Jan-2017 Michael Norrish <Michael.Norrish@nicta.com.au>

Remove unnecessary/unused code from Preterm


# 5bfec379 14-Aug-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Start to refactor parsing-in-context code


# 93e303ad 26-Jul-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Make type-checking handle antiquotes more efficiently

Previously, all antiquoted terms were converted back into preterms
before the machinery in Preterm ever saw them. Now, these terms get to
stay as terms. They are still scanned so that their free variables can
influence those in any surrounding term. This also preserves the way in
which something like

val t = mk_conj(``x:bool``, ``f x:bool``);
``^t``;

raises an exception.


# 8d3d8c0a 25-Jul-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Move Preterm datatype definition to separate file.

As was done with Absyn in 019a332d49, this reduces redundancy and helps
with Poly/ML's pretty-printing


# d45d52a0 25-Jul-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Add entry-points to let parsing to return >1 parse

This is possible in the presence of overloading.

Also some minor tidy-ups in the body of Preterm.sml (more still to be
done in this vein).


# 0432ab57 22-Jul-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Get Defn to compile; also report ambiguous overloads

Set comprehensions will be the next task


# c0d5e065 21-Jul-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Get BasicProvers to compile


# 872e20e7 21-Jul-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Switch type-checking to errormonad everywhere

The optionmonad doesn't hold any advantage, and flipping back and forth
between them was just annoying.


# 580d1ea2 21-Jul-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Get basic kernel working

Interactive behaviour in terms of error messages and the like may still
be broken.


# 37c730f2 20-Jul-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Make progress with functional pretype

The change to pretty-printing raises an exception, but parsing simple
cases seems to work.


# 66762f3b 20-Jul-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Get Preterm to compile


# cb1931ce 20-Jul-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Change error monads to wrap the state & result

So, the state-error monad (called optmonad here) changes from

'state -> ('state * 'a option)

to

'state -> ('state * 'a) option

No doubt there is some precise monad-transformer jargon I could use to
describe this change.

The advantage of the latter is that it makes for an easy lift into the
seqmonad (which replaces option above with seq).


# 6af175af 20-Jul-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Begin to make pretypes purely functional

I want to do without the references that are used in the unification
algorithm.


# 525bfe3c 20-Jan-2016 Michael Norrish <Michael.Norrish@nicta.com.au>

Allow multiple case-like constants in a grammar

Parsing handled; printing still not quite right


# c3ea9397 14-Jun-2014 Michael Norrish <michael.norrish@nicta.com.au>

Make "by" quieter when the provided quotation doesn't type check.

Also make sure that a typecheck error message exactly coincides with the
corresponding exception's message.


# 736c4781 25-Feb-2014 Michael Norrish <michael.norrish@nicta.com.au>

Minor bug fix: ``&3:num`` should parse to a bare ``3:num``.

Otherwise, the result of parsing includes the unusable
``nat_elim__magic`` term.


# 4c8b75f9 24-Feb-2013 Michael Norrish <michael.norrish@nicta.com.au>

Handle variables of different types within case-expressions and Defn.

The code calculating free variables over preterms needs to be aware
that the free variables of

case x of
(a,b) => a + b + c

are x and c. In other words, the variables to the left of the arrow
bind what’s to the right.

Also include a relevant test-case, and improve the output of the
src/tfl/src selftest.


# 09843cd3 21-Feb-2013 Michael Norrish <Michael.Norrish@nicta.com.au>

Make Preterm’s public API a bit richer.


# 54f9badf 07-Apr-2011 Michael Norrish <Michael.Norrish@nicta.com.au>

Add has_unbound_uvar and mk_fun_ty to Pretype API.

Also document some entrypoints there in the .sig suffix.


# a1dead96 19-Feb-2009 Michael Norrish <Michael.Norrish@nicta.com.au>

Attach locations to the error messages generated when overloading
resolution can't find a type for a constant.


# a642994f 27-Nov-2008 Michael Norrish <Michael.Norrish@nicta.com.au>

Fix for a bug found by Anthony, caused by syntactic patterns not
getting their pretype variables assigned properly during inference.

Also adjust wordsScript to remove its change to <>'s precedence, and
adjust the other operators in the same place (-- and ><) to use
set_fixity rather than add_infix.

The advantage of set_fixity is that it removes other rules for the
same token. This avoids complaints about grammar ambiguity. Calls to
add_infix can result in multiple rules for the same token through the
grammar.

So, Anthony, if you really wants <> back at original level, please put
it there with set_fixity. Users inheriting wordsTheory can then cope
with <> having a different precedence from elsewhere.


# 3b2b7c12 11-Nov-2008 Michael Norrish <Michael.Norrish@nicta.com.au>

Modifications to support overloading to a pattern. For example, one
can now do
overload_on ("<>", ``\x y. ~(x = y)``)
The parser does the right thing. The pretty-printer remains
blissfully ignorant for the moment. I don't think Unicode aliasing
will work quite yet either. Backwards compatible in that all the
functions in Parse behave the same if given inputs that were
previously acceptable.

"The parser does the right thing" means the following

- set_fixity "<>" (Infix(NONASSOC, 100));
> val it = () : unit

- ``$<>``;
<<HOL message: inventing new type variable names: 'a>>
> val it = ``\x y. ~(x = y)`` : term

- ``$<> p``;
<<HOL message: inventing new type variable names: 'a>>
> val it = ``\y. ~(p = y)`` : term

- ``p <> q``;
<<HOL message: inventing new type variable names: 'a>>
> val it = ``~(p = q)`` : term

When the pretty-printer is working correctly, the output will probably
be

``\x y. x <> y``

``\y. p <> y``

``p <> q``

In the first two cases, fixing what would appear to the user to be an
odd eta-expansion may be too difficult.


# 349e4895 01-Oct-2008 Michael Norrish <Michael.Norrish@nicta.com.au>

* Remove use of Raise from Parse.sml, as most sub-modules are printing
messages anyway, and if they're not, they should (at least under the
control of a trace variable)
* Also add location information to the 'last error' information in Preterm.


# cba2618e 10-Sep-2008 Michael Norrish <Michael.Norrish@nicta.com.au>

Put the reporting of type-checking errors under the control of a trace
variable, put the message into the exception raised, and also record
the cause of the error in a special reference. This should allow
better programmatic handling of the parser when it might fail.


# 84052801 19-Mar-2007 Anthony Fox <anthony.fox@cl.cam.ac.uk>

Added a hook for a "post processing" phase to the term parser.

Parse.post_process_term : (term -> term) ref

By default this does nothing.


# 18e71cb8 22-Sep-2006 Peter Homeier <palantir@trustworthytools.com>

----------------------------------------------------------------------

Committing in bug fix for a degenerate case.

Modified Files:
Preterm.sml
----------------------------------------------------------------------


# 3d6a421d 22-Sep-2006 Peter Homeier <palantir@trustworthytools.com>

----------------------------------------------------------------------

Committing in fix for minor bug with case expressions.
Before, ``case n of i -> i`` raised an error;
now, it produces ``n``.

Modified Files:
hol98/src/parse/Preterm.sml
----------------------------------------------------------------------


# 956ecc93 22-Sep-2006 Peter Homeier <palantir@trustworthytools.com>

----------------------------------------------------------------------
Enter Log. Lines beginning with `CVS:' are removed automatically

Committing in a new version of literal patterns and case expressions.
This includes a new constant, literal_case : ('a -> 'b) -> ('a -> 'b)
which wraps the previously constructed chains of bool_case expressions
that represent cases branching on literal patterns.

Modified Files:
hol98/src/bool/DefnBase.sml hol98/src/bool/Pmatch.sml
hol98/src/bool/TypeBasePure.sml hol98/src/bool/boolScript.sml
hol98/src/bool/boolSyntax.sig hol98/src/bool/boolSyntax.sml
hol98/src/parse/Preterm.sml hol98/src/tfl/src/Functional.sml
----------------------------------------------------------------------


# 2f7450ac 20-Sep-2006 Michael Norrish <Michael.Norrish@nicta.com.au>

Fix the bug that was masking HOL_ERRs from within remove_case_magic.
Also reformat the function so that it is a little closer to the left
margin.


# e93d1955 30-Aug-2006 Peter Homeier <palantir@trustworthytools.com>

----------------------------------------------------------------------
Committing in more polished versions of the literals in patterns code.
The new results should be alpha-equivalent to before.

Modified Files:
hol98/src/bool/Pmatch.sml hol98/src/parse/Preterm.sml
hol98/src/tfl/src/Functional.sml
----------------------------------------------------------------------


# 30f7dcc1 29-Aug-2006 Peter Homeier <palantir@trustworthytools.com>

----------------------------------------------------------------------

Committing in simplifications/bug fix for parsing literals in patterns.

Modified Files:
hol98/src/parse/Preterm.sml
----------------------------------------------------------------------


# d7a0f3c7 28-Aug-2006 Peter Homeier <palantir@trustworthytools.com>

----------------------------------------------------------------------
Enter Log. Lines beginning with `CVS:' are removed automatically

Committing in fixes to term parser for patterns with literals.
Also fixes bug in Functional.mk_pattern_fn.

Modified Files:
hol98/src/bool/Pmatch.sml hol98/src/bool/TypeBase.sig
hol98/src/bool/TypeBase.sml hol98/src/bool/TypeBasePure.sig
hol98/src/parse/Preterm.sml hol98/src/tfl/src/Functional.sml
----------------------------------------------------------------------


# 6a478866 04-Jul-2006 Michael Norrish <Michael.Norrish@nicta.com.au>

Updates to make large string literals parseable. This required two changes:
* the parsing process doesn't bother making literals into preterms, but
takes them directly to anti-quoted terms. This avoids lots of term
traversals in Preterm.sml
* but remove_case_magic is unavoidable (it is over terms, not preterms),
so rewrite this to be tail recursive. It now also avoids rebuilding
terms unnecessarily. Code for doing this is a little involved.


# 13f030c2 07-Feb-2006 Michael Norrish <Michael.Norrish@nicta.com.au>

Wide-ranging change to make the TypeBase export an interface forcing users
to be concerned about which theory their types are from. Interactive users
of the "induction_of", "axiom_of" and similar functions are thrown the only
bone: they can effectively omit the theory parameter by using "" instead
of a theory name.
Prompted by a bug found by Tom Ridge where it was impossible to define
a pattern matching function on a type with the same name as another type
because the pattern-matching code was using dest_type and TypeBase.read
on just the type-operator name.


# 66141cbf 06-Feb-2006 Michael Norrish <Michael.Norrish@nicta.com.au>

If a case-expression had functional type and was applied to one or more
arguments, the parser bodged it, and didn't convert it correctly.


# ea48238c 03-May-2005 Michael Norrish <Michael.Norrish@nicta.com.au>

Starting to remove redundant (and potentially error-introducing) infix
declarations.


# 512123cb 22-Apr-2005 Konrad Slind <konrad.slind@gmail.com>

Adapting to new Basis (and SML/NJ).


# 118d5a34 25-Sep-2002 Keith Wansbrough <keith@lochan.org>

Welcome to the 1980s... type and overloading errors now report
source-file locations!


# 164e7a23 25-Sep-2002 Keith Wansbrough <keith@lochan.org>

Add a Locn field to each constructor of Preterm.preterm, in
preparation for located type error messages etc.

* Thanks to Joe Hurd for helping locate a bug in an earlier version:
Preterm, while still an equality type, is no longer safe to compare
for equality. Instead, Preterm.eq must be used; this ignores the
locations. (The symptom was a parse_in_context failing to notice
that the binder variables were the same as the bound occurrences,
leading to weird failure in Q.PAT_ASSUM).

* Constrained and Antiq now take records, to accommodate the Locn field.

* Lots of small changes, mainly adding ",...", to code using preterms.

* Pass locations down into the preterm constructor functions.


# dc482ebe 19-Sep-2002 Joe Hurd <joe@gilith.com>

Sacrilege!

+ I abolished the Meson: ... spots!
+ Ditto for <<inventing new type names>> and <<overloading>> messages
+ save_thm now prints the name of the theorem it is saving.

Actually, all of the above only happens when Globals.interactive is
false, i.e., when Holmaking/building the system.

Hope you like the new look!


# f99afe7c 24-Jan-2002 Michael Norrish <Michael.Norrish@nicta.com.au>

Register a trace variable from the type-checking process.
It's tempting to put type-checking error messages under trace variables
as well.


# 03b97a87 08-May-2001 Michael Norrish <Michael.Norrish@nicta.com.au>

Modifications to implement parsing and printing of case expressions.


# 3eb0895b 04-May-2001 Michael Norrish <Michael.Norrish@nicta.com.au>

Case expressions now parse and convert appropriately. Still to print them.


# d8fd568c 03-May-2001 Michael Norrish <Michael.Norrish@nicta.com.au>

Interface by which TypeBase can augment preterm conversion with case
information.


# 5823b125 03-May-2001 Michael Norrish <Michael.Norrish@nicta.com.au>

Even better error-handling. Now copes with
``(1 + x) y``
better.


# afb1a204 03-May-2001 Michael Norrish <Michael.Norrish@nicta.com.au>

Slight extension to error-reporting capability in type-checking.
If you now type in ``1 + T`` where + might be either integer or
natural number addition, then the behaviour is as follows:

- Term`1 + T`;
No possible type for overloaded constant +
Wanted it to have type: :bool -> bool -> bool
! Uncaught exception:
! HOL_ERR


# 67005981 09-Apr-2001 Michael Norrish <Michael.Norrish@nicta.com.au>

Changes to make the type parser handle thy$tyname syntax. This syntax
can only be used as suffixes. Thus: (bool,bool) min$fun, for example.


# 4258a706 15-Mar-2001 Michael Norrish <Michael.Norrish@nicta.com.au>

If an exception is raised in converting terms (using to_term) in the
typechecking, then the value of show_types was not being reset to its
original value.


# 67cbea0e 10-Feb-2001 Konrad Slind <konrad.slind@gmail.com>

Support for new representation of strings.Minor changes.


# 118a9046 15-Nov-2000 Konrad Slind <konrad.slind@gmail.com>

Latest mods for making everything paired.


# 0aaa9d6f 13-Nov-2000 Michael Norrish <Michael.Norrish@nicta.com.au>

Made overload_info type opaque, and added a reverse map to it, under the
hood, which remembers how constants should be printed. Also reworked
Preterm slightly to stop it carking on type-checking errors involving
overloaded constants (things like `0:bool`, if nothing else).


# 5deefb75 03-Nov-2000 Michael Norrish <Michael.Norrish@nicta.com.au>

Changes to the way in which constant names are resolved. There is now
a much simpler map from names in the abstract syntax tree to actual
constant terms; everything now goes through the "overload" map.


# a2511ab7 02-Nov-2000 Michael Norrish <Michael.Norrish@nicta.com.au>

Changes to bring about Kananaskis parser. Known bug exists in
treatment of qualified identifiers.


# beb0ee3c 13-Dec-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Improved the reporting of type errors by having constants be annotated with
their types when printed.


# 2415e019 12-Dec-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Modified warning message to fit onto one line.


# 0b3e5d44 21-Oct-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Reorganised the interface to Preterm; with sensible names for functions,
and all of the useful ones exported.


# 9702a7a5 15-Oct-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Added a comment to print out a message saying that overloading resolution
might take a while in certain cases.


# 37b08cd9 24-Sep-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Greatly improved the efficiency of the treatment of the overloading when
type-checking is done. This results in what appears to be a threefold
speed-up. However, parsing as a whole is still too slow and this is
because of the lexer being so inefficient.


# c3838c80 21-Sep-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Fairly extensive changes, implementing a scheme whereby each theory keeps
track of its own personal grammar value, which can then be relied on by
other libraries. This is in contrast with the term_grammar() value. This
gets changed all the time, and library implementations can't really rely
on it being sensible.

For example, numLib quotes a term involving >. If this symbol was over-
ridden or messed with in some other way, before numLib was loaded, it
would try to parse that term and come a cropper. No more.

Changes in Preterm are more to do with trying to improve the error
reporting from the type-checking, particularly as with regards numerals.


# dc18dcf9 03-Sep-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Many changes, mainly to do with record syntax. Also implemented long IDs
as theory-name$id. All of HOL doesn't quite build because field selection
operator is ->, which is used in the real library. Will change this to be
just a simple "." Have also started on concrete syntax for updates.


# 836b4c7c 26-Aug-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Bug fix; error message when a type constraint unification failed wasn't
being generated.


# 259c8172 23-Aug-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Many changes to allow numerals to be overloaded as well as operators.


# 538a0f08 20-Aug-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Changes to get overloading to properly resolve types. I claimed yesterday
that if an overloaded constant didn't have its type determined by normal
type-checking, then it could be instantiated with any type in the candidate
list of types because if type-checking hadn't constrained it, then it
must be OK. This is rubbish though, because there may be constraints
implicit in other overloaded operators. For example, imagine that ~ is
overloaded to be both a boolean operator (not) and over integers
(negation).
Further, imagine that + is overloaded. Then consider the phrase
~x + 2
If we just guess the first type that comes to hand for x, then we may guess
bool, and this will be wrong, because the + has to go to num->num->num or
int->int->int. So, we need to do backtracking unifications through all
of the possibilities. Hence the use of seqs and seqmonad to implement
this.


# 3bed8d45 19-Aug-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Big raft of changes allowing a simple form of overloading to be supported.


# 076b63b7 13-Aug-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Implementation of type checking is now entirely above the level of the
kernel. New TCPretype module (type-checking pretype) implements much
of the required functionality, including type unification.
Parse_type generalised to target any type providing the appropriate
constructor functions.


# 6e2257c8 11-Aug-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

A number of changes, doing away with the old Pretype and Strm modules.
These changes support the new implementation of the ParseDatatype
module, which now refers to the type parser provided in this directory,
meaning that ParseDatatype can see new user-defined type infixes as and
when they become available.


# 0cccffee 22-Jul-1999 Konrad Slind <konrad.slind@gmail.com>

Small changes to accomodate new-look of portableML.


# accadd48 12-Jul-1999 Konrad Slind <konrad.slind@gmail.com>

Change to antiquote processing. Now free variables in the antiquotation
will affect type inference in the surrounding term. This is the
way it was done in HOL88, but not HOL90.

Also, some now outdated code has been removed.


# 0058df84 28-Jun-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Fixed to bring it up to date with Taupo release 0.
(Changes have come across from parse_branch development.)


# 982c0c3e 17-May-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Modified definition of is_atom in order to get better behaviour while
printing type checking error messages. Numerals are handled correctly,
and constrained terms are also considered atomic.


# caf74236 29-Apr-1999 Michael Norrish <Michael.Norrish@nicta.com.au>

Initial revision