Open atondwal opened 7 years ago
Well that's a new one. Am busy for the next few days; @atondwal can you take a look?
@atondwal the problem here is that Z3 doesn't have any type inference so it thinks that
x = Right y
is ill-typed when
x :: Either Exn Int
y :: Int
here is a minimal Z3/.smt file that demonstrates the problem:
(set-option :auto-config false)
(set-option :model true)
(set-option :model.partial false)
(set-option :smt.mbqi false)
(declare-datatypes (T0 T1) ((Main.Either (Main.Right (selectRight T1)) (Main.Left (selectLeft T0)))))
(declare-fun junk () (Main.Either Int Int))
(declare-fun punk () (Main.Either Bool Int))
(declare-fun escobar () Int)
(push 1)
(assert (= punk (Main.Right escobar)))
(assert (= junk (Main.Right escobar)))
(pop 1)
The solution is to put explicit annotations around the constructor applications, just with the output type:
(set-option :auto-config false)
(set-option :model true)
(set-option :model.partial false)
(set-option :smt.mbqi false)
(declare-datatypes (T0 T1) ((Main.Either (Main.Right (selectRight T1)) (Main.Left (selectLeft T0)))))
(declare-fun junk () (Main.Either Int Int))
(declare-fun punk () (Main.Either Bool Int))
(declare-fun escobar () Int)
(push 1)
;; BAD
;; (assert (= punk (Main.Right escobar)))
;; (assert (= junk (Main.Right escobar)))
;; GOOD
(assert (= punk ((as Main.Right (Main.Either Bool Int)) escobar)))
(assert (= junk ((as Main.Right (Main.Either Int Int)) escobar)))
(pop 1)
For example, see tests/pos/adt_list_2.fq
which generates the SMT query (in .liquid/tests/pos/adt_list_2.fq.smt2`.
(assert (not (= (as emp (LL Int)) (ite (< 1 2) (as emp (LL Int)) (con 1 (as emp (LL Int)))))))
which gives the explicit sort annotation as emp (LL Int)
.
SO can you:
Create a minimal .fq
file test that demonstrates the above problem? (It should basically be a backwards transliteration of the .smt2
file
Then see how the as
annotations are currently generated to extend them as above
SymEnv
) andI added tests/todo/1090.fq
to LF. We should move this issue to that repo.
Unfortunately, there's a bug-within-a-bug. Old version of z3 don't suffer from this monomorphization problem(???) so we can see that under that crash is another similar one.
**** RESULT: ERROR *************************************************************
:1:1-1:1: Error
elaborate makeKnowledge failed on:
lq_anf$##7205759403792801278##d1ZQ == lam lam_arg##1 : (function real Main.Trace) . Main.$$ (lam_arg##1 : func(0, [real;
Main.Trace])) v##a1u1
with error
Cannot unify func(0, [real; Main.Trace]) with (function real Main.Trace) in expression: lam_arg##1
because
Cannot cast lam_arg##1 of sort (function real Main.Trace) to incompatible sort func(0, [real; Main.Trace])
in environment
Main.$$ := func(2, [func(0, [@(1); @(0)]); @(1); @(0)])
v##a1u1 := real
lq_anf$##7205759403792801278##d1ZQ := func(0, [func(0, [real;
Main.Trace]);
Main.Trace])
What is this function real Main.Trace
?
On Tue, Sep 19, 2017 at 1:11 PM, Anish Tondwalkar notifications@github.com wrote:
Unfortunately, there's a bug-within-a-bug. Old version of z3 don't suffer from this monomorphization problem(???) so we can see that under that crash is another
** RESULT: ERROR ***
:1:1-1:1: Error elaborate makeKnowledge failed on: lq_anf$##7205759403792801278##d1ZQ == lam lam_arg##1 : (function real Main.Trace) . Main.$$ (lam_arg##1 : func(0, [real;
Main.Trace])) v##a1u1
with error Cannot unify func(0, [real; Main.Trace]) with (function real Main.Trace) in expression: lam_arg##1 because Cannot cast lam_arg##1 of sort (function real Main.Trace) to incompatible sort func(0, [real; Main.Trace]) in environment Main.$$ := func(2, [func(0, [@(1); @(0)]); @(1); @(0)])
v##a1u1 := real lq_anf$##7205759403792801278##d1ZQ := func(0, [func(0, [real; Main.Trace]); Main.Trace])
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ucsd-progsys/liquidhaskell/issues/1090#issuecomment-330659126, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkuOHZTsZ0Chk_5r_iVG9mxqy-rPKJLks5skB_ogaJpZM4PZ28r .
Anyways, this "inner" bug seems easy to fix -- figure out where this weird
(function real Main.Trace)
is being generated, and replace it with the
actual sort which should be func(0, [real; Main.Trace])
?
On Tue, Sep 19, 2017 at 2:36 PM, Ranjit Jhala jhala@cs.ucsd.edu wrote:
What is this
function real Main.Trace
?On Tue, Sep 19, 2017 at 1:11 PM, Anish Tondwalkar < notifications@github.com> wrote:
Unfortunately, there's a bug-within-a-bug. Old version of z3 don't suffer from this monomorphization problem(???) so we can see that under that crash is another
** RESULT: ERROR ***
:1:1-1:1: Error elaborate makeKnowledge failed on: lq_anf$##7205759403792801278##d1ZQ == lam lam_arg##1 : (function real Main.Trace) . Main.$$ (lam_arg##1 : func(0, [real;
Main.Trace])) v##a1u1
with error Cannot unify func(0, [real; Main.Trace]) with (function real Main.Trace) in expression: lam_arg##1 because Cannot cast lam_arg##1 of sort (function real Main.Trace) to incompatible sort func(0, [real; Main.Trace]) in environment Main.$$ := func(2, [func(0, [@(1); @(0)]); @(1); @(0)])
v##a1u1 := real lq_anf$##7205759403792801278##d1ZQ := func(0, [func(0, [real; Main.Trace]); Main.Trace])
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ucsd-progsys/liquidhaskell/issues/1090#issuecomment-330659126, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkuOHZTsZ0Chk_5r_iVG9mxqy-rPKJLks5skB_ogaJpZM4PZ28r .
Yeah, it shouldn't be too bad. I'll tackle both after my talk tomorrow
On Tue, Sep 19, 2017 at 2:38 PM, Ranjit Jhala notifications@github.com wrote:
Anyways, this "inner" bug seems easy to fix -- figure out where this weird
(function real Main.Trace)
is being generated, and replace it with the actual sort which should befunc(0, [real; Main.Trace])
?On Tue, Sep 19, 2017 at 2:36 PM, Ranjit Jhala jhala@cs.ucsd.edu wrote:
What is this
function real Main.Trace
?On Tue, Sep 19, 2017 at 1:11 PM, Anish Tondwalkar < notifications@github.com> wrote:
Unfortunately, there's a bug-within-a-bug. Old version of z3 don't suffer from this monomorphization problem(???) so we can see that under that crash is another
RESULT: ERROR **
:1:1-1:1: Error elaborate makeKnowledge failed on: lq_anf$##7205759403792801278##d1ZQ == lam lam_arg##1 : (function real Main.Trace) . Main.$$ (lam_arg##1 : func(0, [real;
Main.Trace])) v##a1u1 with error Cannot unify func(0, [real; Main.Trace]) with (function real Main.Trace) in expression: lam_arg##1 because Cannot cast lam_arg##1 of sort (function real Main.Trace) to incompatible sort func(0, [real; Main.Trace]) in environment Main.$$ := func(2, [func(0, [@(1); @(0)]); @(1); @(0)])
v##a1u1 := real
lq_anf$##7205759403792801278##d1ZQ := func(0, [func(0, [real; Main.Trace]); Main.Trace])
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ucsd-progsys/liquidhaskell/issues/ 1090#issuecomment-330659126, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkuOHZTsZ0Chk_5r_ iVG9mxqy-rPKJLks5skB_ogaJpZM4PZ28r .
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/ucsd-progsys/liquidhaskell/issues/1090#issuecomment-330681303, or mute the thread https://github.com/notifications/unsubscribe-auth/AAU8CL-qyC7tFw-LpYhOmF8tTFgWg6Tqks5skDRWgaJpZM4PZ28r .
-- Anish
Q: Why is this email two sentences or less? A: http://two.sentenc.es
why is this closed? i dont think its fixed?
Ah right you moved it to FP; still let's keep it open till the other one is fixed...
I've fixed the first bug (the Either ~~~ Either) business in liquid-fixpoint
https://github.com/ucsd-progsys/liquid-fixpoint/issues/332
via
https://github.com/ucsd-progsys/liquid-fixpoint/pull/333
but the second issue re: makeKnowledge
remains, so keeping this open.
So we're not generating any new exprs in instantiate, so this is being caused by something else altogether:
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Done : is$Foo.Done Foo.Done ~> true
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Fork : is$Foo.Fork Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.New : is$Foo.New Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Put : is$Foo.Put Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Get : is$Foo.Get Foo.Done ~> false
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.HeapExn : is$Foo.HeapExn Foo.HeapExn ~> true
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.Deadlock : is$Foo.Deadlock Foo.HeapExn ~> false
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.MultiplePut : is$Foo.MultiplePut Foo.HeapExn ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Done : is$Foo.Done Foo.Done ~> true
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Fork : is$Foo.Fork Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.New : is$Foo.New Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Put : is$Foo.Put Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Get : is$Foo.Get Foo.Done ~> false
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.HeapExn : is$Foo.HeapExn Foo.HeapExn ~> true
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.Deadlock : is$Foo.Deadlock Foo.HeapExn ~> false
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.MultiplePut : is$Foo.MultiplePut Foo.HeapExn ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Done : is$Foo.Done Foo.Done ~> true
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Fork : is$Foo.Fork Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.New : is$Foo.New Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Put : is$Foo.Put Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Get : is$Foo.Get Foo.Done ~> false
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.HeapExn : is$Foo.HeapExn Foo.HeapExn ~> true
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.Deadlock : is$Foo.Deadlock Foo.HeapExn ~> false
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.MultiplePut : is$Foo.MultiplePut Foo.HeapExn ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Done : is$Foo.Done Foo.Done ~> true
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Fork : is$Foo.Fork Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.New : is$Foo.New Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Put : is$Foo.Put Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Get : is$Foo.Get Foo.Done ~> false
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.HeapExn : is$Foo.HeapExn Foo.HeapExn ~> true
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.Deadlock : is$Foo.Deadlock Foo.HeapExn ~> false
Knowledge : Foo.HeapExn ~> Foo.HeapExn
Rewrite -is$Foo.MultiplePut : is$Foo.MultiplePut Foo.HeapExn ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Done : is$Foo.Done Foo.Done ~> true
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Fork : is$Foo.Fork Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.New : is$Foo.New Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Put : is$Foo.Put Foo.Done ~> false
Knowledge : Foo.Done ~> Foo.Done
Rewrite -is$Foo.Get : is$Foo.Get Foo.Done ~> false
We should file the rel fixpoint bug after we find it
results in: