-
Notifications
You must be signed in to change notification settings - Fork 16
Expose solver mappings to declare non-parametric datatypes #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Assuming that accessors are descructors and recognizers are testers, I am not exactly sure of how this API would be used.
In the documentation there is the following example: define_adt "list" [a]
[ "nil", [];
"const",
[ (Ty.of_var a, Some "hd");
(list(a), Some "tl");
];
]So in your example it would be: To create an instance of If you want, you can leave it as blank for now, I can add it later, you can create an issue and assign me. |
Regarding terminology I used
Yeah exactly. I added a test that shows this: let ptr_adt =
Adt.make "Ptr"
[ Adt.Cons.make "mk-ptr"
~fields:[ ("loc", Some Types.int); ("ofs", Some Types.int) ]
]
in
let ty = Adt.ty ptr_adt in
let loc, ofs =
let acessors = Adt.get_accessors ptr_adt |> List.hd in
(List.nth acessors 0, List.nth acessors 1)
in
let mk_ptr = Adt.get_constructors ptr_adt |> List.hd in
let p1 = const "p1" ty in
let solver = Solver.make () in
Solver.add solver
[ eq p1 (Func.apply mk_ptr [ int 10; int 8 ])
; eq (Func.apply loc [ p1 ]) (int 10)
; eq (Func.apply ofs [ p1 ]) (int 8)
];I find it a bit awkward to use I guess. Maybe I'll change it to: val constructor : string -> t -> func_decl
val selector : string -> t -> func_decl
val tester : string -> t -> func_decl And we can maybe use a
Okok, I will leave it blank for the time being |
I am actually not sure, but that is what I always called them haha (terminology probably changes from a solver to another and from a language to another), but I think those of the SMT-LIB are good.
I agree with this signature.
I think we will need to do a sort of "type-checking" anyway to ensure that a given field or constructor is indeed defined for the type of the term on which it is applied, so a |
25ca4ac to
733ac48
Compare
733ac48 to
9ecd31c
Compare
|
Thanks for the help @hra687261. If we find this API is not very good we can improve on in the future |
This is to allow creating examples such as this:
cc @hra687261 (and anyone who wants to help 😅). I'm not very comfortable with ADTs in SMT, so I would appreciate your help with this one. I left some of my questions below:
Do you thing the API for
AdtandAdt.Consare ok? In particular, do you think theget_constructor,get_recognizers, andget_accessorsprovide an awkward api? Maybe havingval get_constructor : t -> cons_name:string -> Cons.twould be better? (Same logic for the others)I like the
Dolmen_std.Expr.Term.define_adtinterface but I don't really understand how the API works. Do you have some example usages so I can finish the API for dolmen to have adt support in Alt-Ergo?