[isabelle-dev] Isabelle/jEdit: imports

2015-01-16 Thread Christian Sternagel
As of c7f6f01ede15 I noticed the following behavior. Suppose I have a 
theory file with the following content


  theory Foo
  imports
Main
  begin
  end

So far so good. Now I add another import.

  theory Foo
  imports
Main
~~/src/HOL/Tools/Adhoc_Overloading
  begin
  end

By accident this refers to a non-existent file. Instead of a 
corresponding error-message, however, the whole file maintains a lightly 
red background and doesn't seem to be processed at all (i.e., I do not 
get any output if I edit in between begin and end).


cheers

chris
___
isabelle-dev mailing list
isabelle-...@in.tum.de
https://mailmanbroy.informatik.tu-muenchen.de/mailman/listinfo/isabelle-dev


[isabelle-dev] adhoc overloading: ugly output

2015-01-16 Thread Christian Sternagel

Dear all,

in Isabelle2014 as well as c7f6f01ede15 I noticed that the output when 
using adhoc overloading together with abbreviations is not optimal 
(maybe this was already discovered before but I forgot about it). Now, 
it turns out that the same issue (at least superficially it's the same, 
but maybe caused by different reasons) arises also for definitions in 
local theory contexts (or are those the same as mere abbreviations?).


Let me illustrate what I'm talking about by the following example:

theory Foo
imports
  Main
  ~~/src/Tools/Adhoc_Overloading
begin

consts SHARP :: 'a ⇒ 'b (♯)

context
  fixes shp :: 'a ⇒ 'a
begin

adhoc_overloading
  SHARP shp

definition le_sharp (infix ≤⇩♯ 50)
where
  xs ≤⇩♯ ys ≡ list_all2 (λx y. y = x ∨ y = ♯ x) xs ys

term xs ≤⇩♯ ys
text ‹
  Result in @{term Foo.le_sharp ♯ xs ys} instead of
  more desirable @{term xs ≤⇩♯ ys}. (The same happens
  when we turn the above definition into an abbreviation.)
›

end

text ‹
  In the global theory this also happens, but only for
  abbreviations, not for definitions.
›

definition shp = id

adhoc_overloading SHARP shp

definition le_sharp' (infix ≤⇩♯ 50)
where
  xs ≤⇩♯ ys ≡ list_all2 (λx y. y = x ∨ y = ♯ x) xs ys

term xs ≤⇩♯ ys

end

Unfortunately, at the moment I do not have time to look into adhoc 
overloading myself, but let this thread be a reminder. If anybody else 
can provide explanations/comments/solutions, please go ahead!


cheers

chris
___
isabelle-dev mailing list
isabelle-...@in.tum.de
https://mailmanbroy.informatik.tu-muenchen.de/mailman/listinfo/isabelle-dev


Re: [isabelle-dev] [isabelle] TYPE_MATCH exception with adhoc_overloading

2015-01-16 Thread Christian Sternagel
Just a reminder that this old thread is not yet resolved and currently 
I'm essentially stuck.


Independent of my being stuck, could one of the devs apply at least the 
first of the following attached patches (and the second one depending on 
whether dropping semicolons is in general seen as good style or not) 
that somehow drowned in previous emails:


delete
drop_semicolons

cheers

chris

On 12/01/2014 01:56 PM, Christian Sternagel wrote:

Thanks for the valuable pointers Florian!

As far as I understand, type inference is a necessary prerequisite for
expand_abbrevs (so that afterwards matching and instantiating by the
obtained substitution suffice for getting the proper type).

Two thoughts:

1) I wouldn't want to add yet another layer of type-inference directly
before the adhoc_overloading check. Anyway, currently it doesn't even
seem possible to inject something after type inference but before
expand_abbrevs.

2) Even if full type inference was done before the adhoc_overloading
check is executed, matching alone wouldn't suffice.

The reason for 2 is that often (adhoc) overloaded constants have a very
general type (which can't be made more specific while still supporting
all desired variants). Consider e.g. monadic bind, whose type is 'a
= ('b = 'c) = 'd or pure :: 'a = 'b from Andreas' example. More
specifically, for the term pure id type inference will infer type 'b
while the corresponding id has type 'a = 'a and this instance of
pure has type ('a = 'a) = 'b. Thus there is no connection between
the domain- and range-type of pure whatsoever. Now the type of
pure_stream :: 'a1 = 'a1 stream cannot be instantiated to ('a = 'a)
= 'b. Only via unification we can find that with

   ['a1 - ('a = 'a), b' - ('a = 'a) stream]

we actually can insert pure_stream here. The problem (I think) is that
by unification we might inject schematic type variables that stem from
types of variants (like 'a1 above). Into the ongoing check phase whose
context doesn't know about them.

Thus again my questions. Does this seem plausible? And is there a way to
turn such alien schematic type variables into known ones?

cheers

chris

On 11/27/2014 08:50 AM, Florian Haftmann wrote:

Hi Christian,


I'm mostly guessing here. Maybe somebody with deeper knowledge of the
system could comment whether this would be feasible (and also the right
way to go).


I have not spent much thought on the code, but tried to take a bird's
perspective.

The whole matter is about overloaded abbreviations.  Hence, it's about
abbreviation expansion intermingled with type inference.

Having a look syntax_phases.ML


(* standard phases *)

val _ = Context.
  (typ_check 0 standard Proof_Context.standard_typ_check #
   term_check 0 standard
 (fn ctxt = Type_Infer_Context.infer_types ctxt # map
(Proof_Context.expand_abbrevs ctxt)) #
   term_check 100 standard_finish
Proof_Context.standard_term_check_finish #
   term_uncheck 0 standard Proof_Context.standard_term_uncheck);


I see that type inference and abbreviation expansion occur on the same
term check level.  Hence the overloading mechanisms could go here.

Proof_Context.expand_abbrevs essentially boils down to Consts.certify.

Maybe a comparision of these with the current implementation of
adhoc-overloading can give some clues.

Cheers,
Florian

# HG changeset patch
# Parent be4a911aca712cc928d1f798488205ce7c5fac92
typo in description

diff -r be4a911aca71 -r f653343d16ba src/Tools/adhoc_overloading.ML
--- a/src/Tools/adhoc_overloading.MLWed Nov 19 19:12:14 2014 +0100
+++ b/src/Tools/adhoc_overloading.MLFri Nov 21 19:58:22 2014 +0100
@@ -239,7 +239,7 @@
 
 val _ =
   Outer_Syntax.local_theory @{command_spec no_adhoc_overloading}
-add adhoc overloading for constants / fixed variables
+delete adhoc overloading for constants / fixed variables
 (Parse.and_list1 (Parse.const -- Scan.repeat Parse.term)  
adhoc_overloading_cmd false);
 
 end;
# HG changeset patch
# Parent 2b1505ca7ff4d324e4c595374c97fdcc8e4769bb
drop superfluous semicolons

diff -r 2b1505ca7ff4 -r 941653538854 src/Tools/adhoc_overloading.ML
--- a/src/Tools/adhoc_overloading.MLSun Nov 23 20:07:19 2014 +0100
+++ b/src/Tools/adhoc_overloading.MLSun Nov 23 20:09:38 2014 +0100
@@ -19,19 +19,19 @@
 structure Adhoc_Overloading: ADHOC_OVERLOADING =
 struct
 
-val show_variants = Attrib.setup_config_bool @{binding show_variants} (K 
false);
+val show_variants = Attrib.setup_config_bool @{binding show_variants} (K false)
 
 
 (* errors *)
 
 fun err_duplicate_variant oconst =
-  error (Duplicate variant of  ^ quote oconst);
+  error (Duplicate variant of  ^ quote oconst)
 
 fun err_not_a_variant oconst =
-  error (Not a variant of  ^  quote oconst);
+  error (Not a variant of  ^  quote oconst)
 
 fun err_not_overloaded oconst =
-  error (Constant  ^ quote oconst ^  is not declared as overloaded);
+  error (Constant  ^ quote oconst ^  is not declared as overloaded)
 
 fun err_unresolved_overloading ctxt0 (c, T) t