515 fun isQuant [Term.Var _, _] = true |
515 fun isQuant [Term.Var _, _] = true |
516 | isQuant _ = false; |
516 | isQuant _ = false; |
517 |
517 |
518 fun promote (Term.Var v) = Atom (v,[]) |
518 fun promote (Term.Var v) = Atom (v,[]) |
519 | promote (Term.Fn (f,tms)) = |
519 | promote (Term.Fn (f,tms)) = |
520 if Name.equal f truthName andalso null tms then |
520 if Name.equal f truthName andalso List.null tms then |
521 True |
521 True |
522 else if Name.equal f falsityName andalso null tms then |
522 else if Name.equal f falsityName andalso List.null tms then |
523 False |
523 False |
524 else if Name.toString f = !Term.negation andalso length tms = 1 then |
524 else if Name.toString f = !Term.negation andalso length tms = 1 then |
525 Not (promote (hd tms)) |
525 Not (promote (hd tms)) |
526 else if Name.equal f conjunctionName andalso length tms = 2 then |
526 else if Name.equal f conjunctionName andalso length tms = 2 then |
527 And (promote (hd tms), promote (List.nth (tms,1))) |
527 And (promote (hd tms), promote (List.nth (tms,1))) |
547 (* Splitting goals. *) |
547 (* Splitting goals. *) |
548 (* ------------------------------------------------------------------------- *) |
548 (* ------------------------------------------------------------------------- *) |
549 |
549 |
550 local |
550 local |
551 fun add_asms asms goal = |
551 fun add_asms asms goal = |
552 if null asms then goal else Imp (listMkConj (rev asms), goal); |
552 if List.null asms then goal else Imp (listMkConj (rev asms), goal); |
553 |
553 |
554 fun add_var_asms asms v goal = add_asms asms (Forall (v,goal)); |
554 fun add_var_asms asms v goal = add_asms asms (Forall (v,goal)); |
555 |
555 |
556 fun split asms pol fm = |
556 fun split asms pol fm = |
557 case (pol,fm) of |
557 case (pol,fm) of |
561 | (true, And (f1,f2)) => split asms true f1 @ split (f1 :: asms) true f2 |
561 | (true, And (f1,f2)) => split asms true f1 @ split (f1 :: asms) true f2 |
562 | (true, Or (f1,f2)) => split (Not f1 :: asms) true f2 |
562 | (true, Or (f1,f2)) => split (Not f1 :: asms) true f2 |
563 | (true, Imp (f1,f2)) => split (f1 :: asms) true f2 |
563 | (true, Imp (f1,f2)) => split (f1 :: asms) true f2 |
564 | (true, Iff (f1,f2)) => |
564 | (true, Iff (f1,f2)) => |
565 split (f1 :: asms) true f2 @ split (f2 :: asms) true f1 |
565 split (f1 :: asms) true f2 @ split (f2 :: asms) true f1 |
566 | (true, Forall (v,f)) => map (add_var_asms asms v) (split [] true f) |
566 | (true, Forall (v,f)) => List.map (add_var_asms asms v) (split [] true f) |
567 (* Negative splittables *) |
567 (* Negative splittables *) |
568 | (false,False) => [] |
568 | (false,False) => [] |
569 | (false, Not f) => split asms true f |
569 | (false, Not f) => split asms true f |
570 | (false, And (f1,f2)) => split (f1 :: asms) false f2 |
570 | (false, And (f1,f2)) => split (f1 :: asms) false f2 |
571 | (false, Or (f1,f2)) => |
571 | (false, Or (f1,f2)) => |
572 split asms false f1 @ split (Not f1 :: asms) false f2 |
572 split asms false f1 @ split (Not f1 :: asms) false f2 |
573 | (false, Imp (f1,f2)) => split asms true f1 @ split (f1 :: asms) false f2 |
573 | (false, Imp (f1,f2)) => split asms true f1 @ split (f1 :: asms) false f2 |
574 | (false, Iff (f1,f2)) => |
574 | (false, Iff (f1,f2)) => |
575 split (f1 :: asms) false f2 @ split (f2 :: asms) false f1 |
575 split (f1 :: asms) false f2 @ split (f2 :: asms) false f1 |
576 | (false, Exists (v,f)) => map (add_var_asms asms v) (split [] false f) |
576 | (false, Exists (v,f)) => List.map (add_var_asms asms v) (split [] false f) |
577 (* Unsplittables *) |
577 (* Unsplittables *) |
578 | _ => [add_asms asms (if pol then fm else Not fm)]; |
578 | _ => [add_asms asms (if pol then fm else Not fm)]; |
579 in |
579 in |
580 fun splitGoal fm = split [] true fm; |
580 fun splitGoal fm = split [] true fm; |
581 end; |
581 end; |