I have to write a function
match_sequent
with 4 parameters :
- first sequent
- second sequent
- optional subst Γ, with type
form list option
- list subst of Var
and return optional subst Γ and a list of Var.
We have some defined types:
type unop = Neg
type binop = Conj | Disj | Impl | Equiv
type form =
Const of bool
| Var of string
| Unop of unop * form
| Binop of binop * form * form
type sequent = Seq of form list * form
I wrote a function match_form
that matches two forms and calculates a subst if it exists.
like this :
let rec match_form = function
((Const c1,Const c2)::e,sbst)->
if c1=c2 then match_form(e,sbst)
.....
.....
.....
let form1 = Binop(Conj,Var "a",Var "b");; (* a/\b *)
let form2 = Binop(Conj, Binop(Disj, Const true, Const false), Const true);; (* ((p\/q)/\r) *)
(* Test match_form *)
match_form([(form1, form2)],[]);;
(* Output
- : (string * form) list =
[("a", Binop (Disj, Const true, Const false)); ("b", Const true)]
*)
But really I'm struggling with this function match_sequent
.
I try to deal with it but I have no idea how I can do that.
let rec match_sequent (s1 : sequent) (s2 : sequent) ?sopt svar =
match s1,s2 with
|.....;;
Thanks for any help
subst
"substitution"? or "subset"? – Jackson Taleoptional subst Γ, with type form list option
what do you mean by the last "option"? Does it mean the typeoption
, i.e.,Some ... / None
? If so, then in yourmatch_sequent
, you either to givesopt
option
type or give a default value if you want to define an optional parameter?sopt:(sopt = ...)
. caml.inria.fr/pub/docs/u3-ocaml/ocaml051.html – Jackson Tale