Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file expr.ml
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586(* Time-stamp: <modified the 04/12/2013 (at 10:20) by Erwan Jahier> *)(* Expressions *)typet=|Opofoper*tlist|True|False|IvalofNum.num|Fvaloffloat|Varofstringandoper=|And|Or|Xor|Impl|Not|Eq|Ite|Sup|SupEq|Inf|InfEq|Sum|Diff|Prod|Quot|Mod|Div|Uminus|Callofstringlet(to_string:t->string)=funt->letrecauxbt=letb=" "^bin(matchtwith|Op(And,[e1;e2])->(auxbe1)^" and "^(auxbe2)|Op(Or,[e1;e2])->"("^(auxbe1)^" or "^(auxbe2)^")"|Op(Xor,[e1;e2])->"("^(auxbe1)^" xor"^(auxbe2)^")"|Op(Impl,[e1;e2])->"("^(auxbe1)^" =>"^(auxbe2)^")"|Op(Not,[e])->"not("^(auxbe)^")"|Op(Eq,[e1;e2])->(auxbe1)^"="^(auxbe2)(* | Op(Ite,[c;e1;e2]) -> "("^(aux b e1)^"ite" ^(aux b e2) *)|Op(Sup,[e1;e2])->(auxbe1)^">"^(auxbe2)|Op(SupEq,[e1;e2])->(auxbe1)^">="^(auxbe2)|Op(Inf,[e1;e2])->(auxbe1)^"<"^(auxbe2)|Op(InfEq,[e1;e2])->(auxbe1)^"<="^(auxbe2)|Op(Sum,[e1;e2])->"("^(auxbe1)^"+"^(auxbe2)^")"|Op(Diff,[e1;e2])->"("^(auxbe1)^"-"^(auxbe2)^")"|Op(Prod,[e1;e2])->(auxbe1)^"*"^(auxbe2)|Op(Quot,[e1;e2])->(auxbe1)^"/"^(auxbe2)|Op(Mod,[e1;e2])->"("^(auxbe1)^"mod"^(auxbe2)^")"|Op(Div,[e1;e2])->(auxbe1)^"/"^(auxbe2)|Op(op,l)->(oper_auxbop)^"(\n"^b^((String.concat(",\n"^b)(List.map(auxb)l))^"\n"^b^")")|True->"t"|False->"f"|Ival(n)->Num.string_of_numn|Fval(f)->string_of_floatf|Var(str)->str)andoper_auxb=function|And->"and"|Or->"or"|Xor->"xor"|Impl->"impl"|Not->"not"|Eq->"eq"|Ite->"ite"|Sup->"sup"|SupEq->"supeq"|Inf->"inf"|InfEq->"infeq"|Sum->"sum"|Diff->"diff"|Prod->"prod"|Quot->"quot"|Mod->"mod"|Div->"div"|Uminus->"uminus"|Callstr->strinaux""tletdumpe=print_string((to_stringe)^"\n")letrec(simplify:t->t)=funt->matchtwith|Op(And,(Op(And,l)::tail))->simplify(Op(And,(l@tail)))|Op(Or,(Op(Or,l)::tail))->simplify(Op(Or,(l@tail)))|Op(Sum,(Op(Sum,l)::tail))->simplify(Op(Sum,(l@tail)))|Op(Not,[Op(Not,[e])])->simplifye|Op(Not,[Op(Sup,[e1;e2])])->Op(InfEq,[simplifye1;simplifye2])|Op(Not,[Op(Inf,[e1;e2])])->Op(SupEq,[simplifye1;simplifye2])|Op(Not,[Op(SupEq,[e1;e2])])->Op(Inf,[simplifye1;simplifye2])|Op(Not,[Op(InfEq,[e1;e2])])->Op(Sup,[simplifye1;simplifye2])|Op(op,l)->Op(op,List.mapsimplifyl)|e->e