izgzhen / z3-encoding

High-level assertion encoding to Z3 solver
MIT License
5 stars 3 forks source link

Revise the type inference part #3

Closed izgzhen closed 8 years ago

izgzhen commented 8 years ago

Esp. the higher order structures like Map, Set. Interestingly, currently we don't need to infer function type because there is a SMTContext::_funcContext which should include everything you need.

izgzhen commented 8 years ago

I am trying to embed the small language directly inside Haskell. See embed branch for details.

izgzhen commented 8 years ago

Looks like the easiest solution to embed qualifier would be make variable not embedded at all...I should make a demo lang for this.

izgzhen commented 8 years ago

@zjhmale Ok, I am finally comfortable with its current status now(强迫症终于缓和一点了,赶紧滚去复习期末考), although it has several problems:

First, Assertion is not type-safe, for example forall v1 v2. (Z3Encoded v1, Z3Encoded v2) => v1 -> v2 -> Assertion, it doesn't require v1 and v2 to be the same Eq v => v. We can make stronger requirements here, but that would render the naive term language (rather than a real eDSL in Haskell) in Z3.Demo invalid.

Second, pretty lame is that the qualifier still needs a String binder and a concrete Type. By using Template Haskell, we might be able to resolve this (though it can be difficult IMO).

zjhmale commented 8 years ago

it seems difficult to make HeteroList deriving Eq so as to derive Eq for Term 😂 , i will try later.

it doesn't require v1 and v2 to be the same Eq v => v.

agreed. binder here is a little bit redundent.

Second, pretty lame is that the qualifier still needs a String binder and a concrete Type. By using Template Haskell, we might be able to resolve this (though it can be difficult IMO).

izgzhen commented 8 years ago

You are right, HeteroList is a bad idea. Originally we have manually typed term, so it is possible to bake the Eq logic into our Infer part

izgzhen commented 8 years ago

Looks like TH would be the only way out, unless we manually manage the the Inference etc. It works good, just not that extensible and elegant

zjhmale commented 8 years ago

writing Macro is eggache 😂

Looks like TH would be the only way out, unless we manually manage the the Inference etc. It works good, just not that extensible and elegant

izgzhen commented 8 years ago

I agree

On 8 Jun 2016, at 8:46 PM, (λ . λ) notifications@github.com wrote:

writing Macro is eggache 😂

Looks like TH would be the only way out, unless we manually manage the the Inference etc. It works good, just not that extensible and elegant

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/izgzhen/z3-encoding/issues/3#issuecomment-224577782, or mute the thread https://github.com/notifications/unsubscribe/AG1hxj0EM1EDgVsTZeyx3G8rC8vi4IEBks5qJrmjgaJpZM4Iv5i8.

zjhmale commented 8 years ago

sorry, i work on #6 before i see this comment, and do you mean hard code the Eq logic? maybe i'm misunderstanding with this comment.

You are right, HeteroList is a bad idea. Originally we have manually typed term, so it is possible to bake the Eq logic into our Infer part

zjhmale commented 8 years ago

actually i can not figure out the infer part for now, maybe i should play with z3-haskell first, i used to play with z3 use smtlib2 format scripts.

izgzhen commented 8 years ago

@zjhmale I originally mean to write something like forall v. (Eq v, Z3Encoded v) => v -> v -> Assertion, but it will require us to inject everything that can appear at that place to be embedded into Haskell type system.

6 is cool anyway, better than no constraint at all :P

izgzhen commented 8 years ago

@zjhmale no hurry. The z3-haskell's interface is not type-safe anyway, so we are not worse at least. I think it is an interesting topic to work on though.

zjhmale commented 8 years ago

ok. so... (那我先去复习啦 😂 )

izgzhen commented 8 years ago

I am planning to re-introduce type checking to Z3Pred

izgzhen commented 8 years ago

Now it is checked by Haskell compiler