We are pleased to announce the Kananaskis-13 release of HOL 4.
(Released: 20 August 2019)
Contents
- New features
- Bugs fixed
- New theories
- New tools
- New Examples
- Incompatibilities
New features:
-
We have implemented new syntaxes for
store_thmandsave_thm, which better satisfy the recommendation thatname1andname2below should be the same:val name1 = store_thm("name2", tm, tac);Now we can remove the “code smell” by writing
Theorem name: term-syntax Proof tac QEDwhich might look like
Theorem name: ∀x. P x ⇒ Q x Proof rpt strip_tac >> ... QEDThis latter form must have the
ProofandQEDkeywords in column 0 in order for the lexing machinery to detect the end of the term and tactic respectively.
Both forms map to applications ofQ.store_thmunderneath, with an ML binding also made to the appropriate name.
Both forms allow for theorem attributes to be associated with the name, so that one can writeTheorem ADD0[simp]: ∀x. x + 0 = x Proof tactic QEDFinally, to replace
val nm = save_thm(“nm”, thm_expr);one can now write
Theorem nm = thm_exprThese names can also be given attributes in the same way.
There is also a new
localattribute available for use withstore_thm,save_thmand theTheoremsyntax above.
This attribute causes a theorem to not be exported whenexport_theoryis called, making it local-only.
Use ofTheorem-localis thus an alternative to usingproveorQ.prove.
In addition, theTheorem-localcombination can be abbreviated withTriviality; one can writeTriviality foo[...]instead ofTheorem foo[local,...].
-
Relatedly, there is a similar syntax for making definitions.
The idiom is to writeDefinition name[attrs]: def EndOr
Definition name[attrs]: def Termination tactic EndThe latter form maps to a call to
tDefine; the former toxDefine.
In both cases, thenameis taken to be the name of the theorem stored to disk (it does not have a suffix such as_defappended to it), and is also the name of the local SML binding.
The attributes given byattrscan be any standard attribute (such assimp), and/or drawn fromDefinition-specific options:- the attribute
schematicalllows the definition to be schematic; - the attribute
nocomputestops the definition from being added to the global compset used byEVAL - the attribute
induction=inamemakes the induction theorem that is automatically derived for definitions with interesting termination be callediname.
If this is omitted, the name chosen will be derived from thenameof the definition: ifnameends with_defor_DEF, the induction name will replace this suffix with_indor_INDrespectively; otherwise the induction name will simply benamewith_indappended.
Whether or not the
induction=attribute is used, the induction theorem is also made available as an SML binding under the appropriate name.
This means that one does not need to follow one’s definition with a call to something likeDB.fetchortheoremjust to make the induction theorem available at the SML level. - the attribute
-
Similarly, there are analogous
InductiveandCoInductivesyntaxes for defining inductive and coinductive relations (usingHol_relnandHol_corelnunderneath).
The syntax isInductive stem: quoted term material Endor
CoInductive stem: quoted term material Endwhere, as above, the
Inductive,CoInductiveandEndkeywords must be in the leftmost column of the script file.
Thestempart of the syntax drives the selection of the various theorem names (e.g.,stem_rules,stem_ind,stem_casesandstem_strongindfor inductive definitions) for both the SML environment and the exported theory.
The actual names of new constants in the quoted term material do not affect these bindings. -
Finally, there are new syntaxes for
Datatypeand type-abbreviation.
Users can replaceval _ = Datatype`...`withDatatype: ... Endand
val _ = type_abbrev("name", ty)withType name = tyif the abbreviation should introduce pretty-printing (which would be done with
type_abbrev_pp), the syntax isType name[pp] = tyNote that in both
Typeforms thetyis a correct ML value, and may thus require quoting.
For example, thesetabbreviation is established withType set = “:α -> bool” -
Holmake now understands targets whose suffixes are the string
Theoryto be instructions to build all of the files associated with a theory.
Previously, to specifically getfooTheorybuilt, it was necessary to writeHolmake fooTheory.uowhich is not particularly intuitive.
Thanks to Magnus Myreen for the feature suggestion.
-
Users can now remove rewrites from simpsets, adjusting the behaviour of the simplifier.
This can be done with the-*operatorSIMP_TAC (bool_ss -* [“APPEND_ASSOC”]) [] >> ...or with the
Exclform in a theorem list:simp[Excl “APPEND_ASSOC”] >> ...The stateful simpset (which is behind
srw_ss()and tactics such assimp,rwandfs) can also be affected more permanently by making calls todelsimps:val _ = delsimps [“APPEND_ASSOC”]Such a call will affect the stateful simpset for the rest of the containing script-file and in all scripts that inherit this theory.
As is typical, there is atemp_delsimpsthat removes the rewrite for the containing script-file only. -
Users can now require that a simplification tactic use particular rewrites.
This is done with theReq0andReqDspecial forms.
TheReq0form requires that the goalstate(s) pertaining after the application of the tactic have no sub-terms that match the pattern of the theorems’ left-hand sides.
TheReqDform requires that the number of matching sub-terms should have decreased.
(This latter is implicitly a requirement that the original goal did have some matching sub-terms.)
We hope that both forms will be useful in creating maintainable tactics.
See the DESCRIPTION manual for more details.Thanks to Magnus Myreen for this feature suggestion (Github issue).
-
The
emacseditor mode now automatically switches new HOL sessions to the directory of the (presumably script) file where the command is invoked.
Relatedly there is a backwards incompatibility: the commands for creating new sessions now also always create fresh sessions (previously, they would try to make an existing session visible if there was one running). -
The
emacsmode’sM-h Hcommand used to try to send the whole buffer to the new HOL session when there was no region high-lighted.
Now the behaviour is to send everything up to the cursor.
This seems preferable: it helps when debugging to be able to have everything up to a problem-point immediately fed into a fresh session.
(The loading of the material (whole prefix or selected region) is done “quietly”, with the interactive flag false.) -
Holmakefiles can now refer to the new variable
DEFAULT_TARGETSin order to generate a list of the targets in the current directory that Holmake would attempt to build by default.
This provides an easier way to adjust makefiles than that suggested in the release notes for Kananaskis-10. -
String literals can now be injected into other types (in much the same way as numeric literals are injected into types such as
realandrat).
Either the standard double-quotes can be used, or two flavours of guillemet, allowing e.g.,“‹foo bar›”, and“«injected-HOL-string\n»”.
Ambiguous situations are resolved with the standard overloading resolution machinery.
See the REFERENCE manual’s description of theadd_strliteral_formfunction for details. -
The
Q.SPEC_THENfunction (also available asqspec_theninbossLib) now type-instantiates provided theorems à laISPEC, and tries all possible parses of the provided quotation in order to make this work.
TheQ.ISPEC_THENfunction is deprecated.
Bugs fixed:
smlTimeout.timeout: The thread attributes are now given which eliminates concurrency issues during TacticToe recording.
This function now raises the exceptionFunctionTimeoutinstead ofInterruptif the argument function exceeds the time limit.
New theories:
-
real_topologyTheory: a rather complete theory of Elementary
Topology in Euclidean Space, ported by Muhammad Qasim and Osman
Hasan from HOL-light (up to 2015). The part of General Topology
(independent ofrealTheory) is now available at
topologyTheory; the oldtopologyTheoryis renamed to
metricTheory.There is a minor backwards-incompatibility: old proof scripts using
the metric-related results in previoustopologyTheoryshould now
openmetricTheoryinstead. (Thanks to Chun Tian for this work.) -
nlistTheory: a development of the bijection between lists of natural numbers and natural numbers.
Many operations on lists transfer across to the numbers in obvious ways.
The functions demonstrating the bijection arelistOfN : num -> num listand
nlist_of : num list -> numThis material is an extension of a basic treatment that was already part of the computability example.
Thanks to Elliot Catt and Yiming Xu for help with this theory’s development. -
bisimulationTheory: a basic theory of bisimulation (strong and weak)
defined on general labeled transitions (of type:'a->'b->'a->bool),
mostly abstracted fromexamples/CCS.
(Thanks to James Shaker and Chun Tian for this work.)
New tools:
-
HolyHammer is now able to exports HOL4 formulas to the TPTP formats: TFF0, TFF1, THF0 and THF1.
Type encodings have been adapted from the existing FOF translation to make use of the increase in type
expressivity provided by these different formats. -
It is now possible to train feedforward neural networks with
mlNeuralNetworkand tree neural networks withmlTreeNeuralNetwork.
The shape of a tree neural network is described by a term, making it handy to train
functions from terms to real numbers. -
An implementation of Monte Carlo tree search relying on an existing policy and value is now provided in
psMCTS.
The policy is a function that given a particular situation returns a prior probability for each possible choice.
The value is a function that evaluates how promising a situation is by a real number between 0 and 1. -
Tactic to automate some routine
pred_settheorems by reduction
to FOL (bossLib):SET_TAC,ASM_SET_TACandSET_RULE,
ported from HOL Light. Many simple set-theoretic results can be
directly proved without finding needed lemmas inpred_setTheory.
(Thanks to HVG concordia and Chun Tian for this work.)
New examples:
-
[
examples/logic/folcompactness] A port of some material from HOL Light (this commit), about compactness and canonical models for First Order Logic.
This is work described in John Harrison’s Formalizing Basic First Order Model Theory.Results include
⊢ INFINITE 𝕌(:α) ∧ ffinsat (:α) s ⇒ satisfiable (:α) sand
⊢ INFINITE 𝕌(:α) ⇒ (entails (:α) Γ ϕ ⇔ ∃Γ₀. FINITE Γ₀ ∧ Γ₀ ⊆ Γ ∧ entails (:α) Γ₀ ϕ)
Incompatibilities:
-
The
termtype is now declared so that it is no longer what SML refers to as an “equality type”.
This means that SML code that attempts to use=or<>on types that include terms will now fail to compile.
Unlike in Haskell, we cannot redefine the behaviour of equality and must accept the SML implementation’s best guess as to what equality is.
Unfortunately, the SML equality on terms is not correct.
As has long been appreciated, it distinguishes“λx.x”and“λy.y”, which is bad enough.
However, in the standard kernel, where explicit substitutions may be present in a term representation, it can also distinguish terms that are not only semantically identical, but also even print the same.This incompatibility will mostly affect people writing SML code.
If broken code is directly calling=on terms, the~~infix operator can be used instead (this is the tupled version ofaconv).
Similarly,<>can be replaced by!~.
If broken code includes something likeexpr <> NONEandexprhas typeterm option, then combinators fromPortablefor building equality tests should be used.
In particular, the above could be rewritten tonot (option_eq aconv expr NONE)It is possible that a tool will want to compare terms for exact syntactic equality up to choice of bound names.
Theidenticalfunction can be used for this.
Note that we strongly believe that uses of this function will only occur in very niche cases.
For example, it is used just twice in the distribution as of February 2019.There are a number of term-specific helper functions defined in
boolLibto help in writing specific cases.
For exampleval memt : term list -> term -> bool val goal_eq : (term list * term) -> (term list * term) -> bool val tassoc : term -> (term * ‘a) list -> ‘a val xtm_eq : (‘’a * term) -> (‘’a * term) -> bool -
The
Holmaketool now behaves with the--qofbehaviour enabled by default.
This means that script files which have a tactic failure occur will cause the building of the corresponding theory to fail, rather than having the build continue with the theorem “cheated”.
We think this will be less confusing for new users.
Experts who do want to have script files continue past such errors can use the--noqofoption to enable the old behaviour. -
When running with Poly/ML, we now require at least version 5.7.0.
-
The
type_abbrevfunction now affects only the type parser.
The pretty-printer will not use the new abbreviation when printing types.
If the old behaviour of printing the abbreviations as well as parsing them is desired, the new entrypointtype_abbrev_ppshould be used. -
The
Globals.primingreference variable has been removed.
All priming done by the kernel is now by appending extra prime (apostrophe) characters to the names of variables.
This also means that this is the only form of variation introduced by thevariantfunction.
However, there is also a newnumvariantfunction, which makes the varying function behave as if the oldGlobals.primingwas set toSOME ""(introduces and increments a numeric suffix). -
We have made equality a tightly binding infix rather than a loose one.
This means that a term like“p = q ∧ r”now parses differently, and means“(p = q) ∧ r”, rather than“p = (q ∧ r)”.
For the weak binding, the “iff” alternative is probably better; thus:“p <=> q ∧ r”(or use the Unicode⇔).
To fix a whole script file at one stroke, one can revert to the old, loosely binding equality withval _ = ParseExtras.temp_loose_equality()To fix a whole family of theories that inherit from a few ancestors, add
val _ = ParseExtras.loose_equality()to the ancestral script files, and then the reversion to the old style of grammar will be inherited by all subsequent theories as well.
-
By default, goals are now printed with the trace variable
"Goalstack.print_goal_at_top"set to false.
This means goals now print like0. p 1. q ------------------------------------ rThe motivation is that when goal-states are very large, the conclusion (which we assume is the most important part of the state) runs no risk of disappearing off the top of the screen.
We also believe that having the conclusion and most recent assumption at the bottom of the screen is easier for human eyes to track.
The trace variable can be changed back to the old behaviour with:val _ = set_trace "Goalstack.print_goal_at_top" 1;This instruction can be put into script files, or (better) put into your
~/.hol-config.smlfile so that all interactive sessions are automatically adjusted. -
This is arguably also a bug-fix: it is now impossible to rebind a theorem to a name that was associated with a definition, and have the new theorem silently be added to the
EVALcompset for future theories’ benefit.
In other words, it was previously possible to doval _ = Define`foo x = x + 1`; EVAL “foo 6”; (* returns ⊢ foo 6 = 7 *) val _ = Q.save_thm (“foo_def”, thm);and have the effect be that
thmgoes intoEVAL’s compset in descendent theories.Now, when this happens, the change to the persistent compset is dropped.
If the user wants the newfoo_defto appear in theEVAL-compset in future theories, they must change the call tosave_thmto use the name"foo_def[compute]".
Now, as before, the oldfoo_defcannot be seen by future theories at all, and so certainly will not be in theEVAL-compset. -
In some circumstances, the function definition machinery would create a theorem called
foo_def_compute.
(Such theorems would be rewrites for functions that were defined using theSUCconstructor, and would be useful for rewriting with numeral arguments.)
Now, such theorems are calledfoo_compute.
As before, such theorems are automatically added toEVAL’s built-in compset. -
The global toggle
allow_schema_definitionhas turned into a feedback trace variable.
Users typically use theDefineSchemaentrypoint and can continue to do so.
Users can also pass theschematicattribute with the newDefinitionsyntax (see above).
Programmers should change uses ofwith_flagtoFeedback.trace. -
The theorem
MEM_DROPinlistTheoryhas been restated asMEM x (DROP n ls) ⇔ ∃m. m + n < LENGTH ls ∧ x = EL (m + n) lsThe identically named
MEM_DROPinrich_listTheoryhas been deleted because it is subsumed byMEM_DROP_IMPinrich_listTheory, which statesMEM x (DROP n ls) ⇒ MEM x ls -
The
drulefamily of tactics (and the underlyingmp_then) now generalise the implicational theorem argument (withGEN_ALL) before looking for instantiations.
If the old behaviour is desired, where free variables are fixed, replacingdrulewithFREEZE_THEN drulewill stop generalisation of all the implicational theorem’s variables.
Unfortunately, this may then prevent the matching from occurring at all.
In this situation (where some free variables need to be instantiated to make the match go through and the remainder have to be appear as new “local constants” serendipitously linking up with existing free variables in the goal, or if there are type variables that need to be instantiated),drulemay need to be replaced withdrule_then (qspecl_then [‘a’, ‘b’,...] mp_tac)where
‘a’,‘b’etc. respecialise the original theorem.Alternatively, there is a more involved code that more robustly reimplements the old behaviour available as part of the CakeML project.