@@ -618,9 +618,8 @@ let rename proposition formula =
618
618
(* DSNF TRANSFORMATIONS *)
619
619
(* *****************************************************************)
620
620
621
- (* this reference controls how fo formulas are processed: if false,
622
- then by de Morgan laws, by renaming else*)
623
- let useFOrenaming = ref false ;;
621
+ (* the useFOrenaming argument controls how fo formulas are processed:
622
+ if false, then by de Morgan laws, by renaming else*)
624
623
625
624
(*
626
625
(* Transformation to CNF by renaming *)
@@ -675,13 +674,13 @@ let fodsnfselect form =
675
674
(* iP uP sP eP *)
676
675
(* *)
677
676
(* ASSUME that formula is in NNF *)
678
- let rec dsnfWrap form =
677
+ let rec dsnfWrap ~ useFOrenaming form =
679
678
debug (" dsnfWrap input: " ^ (string_of_formula form));
680
679
match form with
681
680
| f when (isTemporalFree f) -> (f, [] , [] , [] )
682
681
| And (x ,y ) ->
683
- let (iP1, uP1,sP1,eP1) = dsnfWrap x
684
- and (iP2, uP2,sP2,eP2) = dsnfWrap y
682
+ let (iP1, uP1,sP1,eP1) = dsnfWrap ~use FOrenaming x
683
+ and (iP2, uP2,sP2,eP2) = dsnfWrap ~use FOrenaming y
685
684
in (And (iP1, iP2), union uP1 uP2, union sP1 sP2, union eP1 eP2)
686
685
| Always (f ) when (isTemporalFree f) ->
687
686
(True , [f], [] , [] )
@@ -695,9 +694,9 @@ let rec dsnfWrap form =
695
694
(True , [] , [Always (Or (lhs,rhs))], [] )
696
695
697
696
(* else use the standard transformations *)
698
- | _ -> dsnf form
697
+ | _ -> dsnf ~use FOrenaming form
699
698
700
- and dsnf form =
699
+ and dsnf ~ useFOrenaming form =
701
700
debug (" dsnf input: " ^ (string_of_formula form));
702
701
(* if isTemporalFree form *)
703
702
(* then fodsnfselect form *)
@@ -712,26 +711,26 @@ and dsnf form =
712
711
match form with
713
712
(* booleans go first *)
714
713
| Not x ->
715
- let (iP,uP,sP,eP) = dsnf x
714
+ let (iP,uP,sP,eP) = dsnf ~use FOrenaming x
716
715
in (Not (iP), uP,sP,eP)
717
716
| And (x ,y ) ->
718
- let (iP1, uP1,sP1,eP1) = dsnf x
719
- and (iP2, uP2,sP2,eP2) = dsnf y
717
+ let (iP1, uP1,sP1,eP1) = dsnf ~use FOrenaming x
718
+ and (iP2, uP2,sP2,eP2) = dsnf ~use FOrenaming y
720
719
in (And (iP1, iP2), union uP1 uP2, union sP1 sP2, union eP1 eP2)
721
720
(* | Or(x,y) ->
722
- let (iP1, uP1,sP1,eP1) = dsnf x
723
- and (iP2, uP2,sP2,eP2) = dsnf y
721
+ let (iP1, uP1,sP1,eP1) = dsnf ~useFOrenaming x
722
+ and (iP2, uP2,sP2,eP2) = dsnf ~useFOrenaming y
724
723
in (Or(iP1, iP2), union uP1 uP2, union sP1 sP2, union eP1 eP2)*)
725
- | Or (f , g ) when ((not ! useFOrenaming) || (isLiteral f) || (isLiteral g)) ->
726
- let (iP1, uP1, sP1, eP1) = dsnf f
727
- and (iP2, uP2, sP2, eP2) = dsnf g
724
+ | Or (f , g ) when ((not useFOrenaming) || (isLiteral f) || (isLiteral g)) ->
725
+ let (iP1, uP1, sP1, eP1) = dsnf ~use FOrenaming f
726
+ and (iP2, uP2, sP2, eP2) = dsnf ~use FOrenaming g
728
727
in
729
728
(Or (iP1, iP2), (union uP1 uP2), (union sP1 sP2), (union eP1 eP2))
730
- | Or (f , g ) when (! useFOrenaming) (* both are non-litarls & useFOrenaming *) ->
729
+ | Or (f , g ) when (useFOrenaming) (* both are non-litarls & useFOrenaming *) ->
731
730
let newP = newLiteral (freeVars f)
732
- and (iP1, uP1, sP1, eP1) = dsnf f
731
+ and (iP1, uP1, sP1, eP1) = dsnf ~use FOrenaming f
733
732
in setSeen iP1 newP ;
734
- let (iP2, uP2, sP2, eP2) = dsnf g
733
+ let (iP2, uP2, sP2, eP2) = dsnf ~use FOrenaming g
735
734
in
736
735
(Or (newP, iP2),
737
736
(rename newP iP1)::(union uP1 uP2), (union sP1 sP2), (union eP1 eP2))
@@ -742,15 +741,15 @@ and dsnf form =
742
741
in (Implies(iP1, iP2), union uP1 uP2, union sP1 sP2, union eP1 eP2)*)
743
742
(* Quantifiers *)
744
743
| Forall (v ,y ) ->
745
- let (iP,uP,sP,eP) = dsnf y
744
+ let (iP,uP,sP,eP) = dsnf ~use FOrenaming y
746
745
in (Forall (v, iP), uP,sP,eP)
747
746
| Exists (v ,y ) ->
748
- let (iP,uP,sP,eP) = dsnf y
747
+ let (iP,uP,sP,eP) = dsnf ~use FOrenaming y
749
748
in (Exists (v, iP), uP,sP,eP)
750
749
(* Temporal operators *)
751
750
| Always (f ) ->
752
751
let newP = newLiteral (freeVars f)
753
- and (iP,uP,sP,eP) = dsnf f
752
+ and (iP,uP,sP,eP) = dsnf ~use FOrenaming f
754
753
in setSeen (Always (f)) newP ;
755
754
(newP,
756
755
(rename newP iP)::uP,
@@ -764,7 +763,7 @@ and dsnf form =
764
763
if (isLiteral f) then f
765
764
else (newLiteral (freeVars f))
766
765
)
767
- and (iP,uP,sP,eP) = dsnf f
766
+ and (iP,uP,sP,eP) = dsnf ~use FOrenaming f
768
767
in setSeen (Next (f)) newP ;
769
768
(newP,
770
769
(if (isLiteral f) then uP else
@@ -775,7 +774,7 @@ and dsnf form =
775
774
| Sometime (f ) ->
776
775
let newP = newLiteral (freeVars f)
777
776
and newQ = newLiteral (freeVars f)
778
- and (iP,uP,sP,eP) = dsnf f
777
+ and (iP,uP,sP,eP) = dsnf ~use FOrenaming f
779
778
in setSeen (Sometime (f)) newP ;
780
779
(newP,
781
780
(rename newQ iP)::uP,
@@ -786,24 +785,24 @@ and dsnf form =
786
785
if not (isLiteral f)
787
786
then
788
787
let newP = newLiteral (freeVars (Until (f,g)))
789
- in let (iP,uP,sP,eP) = dsnf (Until (newP, g))
790
- and (iP2,uP2,sP2,eP2) = dsnf (f)
788
+ in let (iP,uP,sP,eP) = dsnf ~use FOrenaming (Until (newP, g))
789
+ and (iP2,uP2,sP2,eP2) = dsnf ~use FOrenaming (f)
791
790
in (iP,
792
791
(rename newP iP2)::(uP@ uP2),
793
792
sP@ sP2, eP@ eP2)
794
793
else if not (isLiteral g)
795
794
then
796
795
let newQ = newLiteral (freeVars (Until (f,g)))
797
- in let (iP,uP,sP,eP) = dsnf (Until (f, newQ))
798
- and (iP2,uP2,sP2,eP2) = dsnf (g)
796
+ in let (iP,uP,sP,eP) = dsnf ~use FOrenaming (Until (f, newQ))
797
+ and (iP2,uP2,sP2,eP2) = dsnf ~use FOrenaming (g)
799
798
in (iP,
800
799
(rename newQ iP2)::(uP@ uP2),
801
800
sP@ sP2, eP@ eP2)
802
801
else (* Both f and g are atoms *)
803
802
let newP = newLiteral (freeVars (Until (f,g)))
804
803
and newQ = newLiteral (freeVars (Until (f,g)))
805
- and (iP1,uP1,sP1,eP1) = dsnf f
806
- and (iP2,uP2,sP2,eP2) = dsnf g
804
+ and (iP1,uP1,sP1,eP1) = dsnf ~use FOrenaming f
805
+ and (iP2,uP2,sP2,eP2) = dsnf ~use FOrenaming g
807
806
in setSeen (Until (f,g)) newP ;
808
807
(newP,
809
808
(
@@ -820,24 +819,24 @@ and dsnf form =
820
819
if not (isLiteral f)
821
820
then
822
821
let newP = newLiteral (freeVars (Unless (f,g)))
823
- in let (iP,uP,sP,eP) = dsnf (Unless (newP, g))
824
- and (iP2,uP2,sP2,eP2) = dsnf (f)
822
+ in let (iP,uP,sP,eP) = dsnf ~use FOrenaming (Unless (newP, g))
823
+ and (iP2,uP2,sP2,eP2) = dsnf ~use FOrenaming (f)
825
824
in (iP,
826
825
(rename newP iP2)::(uP@ uP2),
827
826
sP@ sP2,eP@ eP2)
828
827
else if not (isLiteral g)
829
828
then
830
829
let newQ = newLiteral (freeVars (Unless (f,g)))
831
- in let (iP,uP,sP,eP) = dsnf (Unless (f, newQ))
832
- and (iP2,uP2,sP2,eP2) = dsnf (g)
830
+ in let (iP,uP,sP,eP) = dsnf ~use FOrenaming (Unless (f, newQ))
831
+ and (iP2,uP2,sP2,eP2) = dsnf ~use FOrenaming (g)
833
832
in (iP,
834
833
(rename newQ iP2)::(uP@ uP2),
835
834
sP@ sP2,eP@ eP2)
836
835
else (* Both f and g are atoms *)
837
836
let newP = newLiteral (freeVars (Unless (f,g)))
838
837
and newQ = newLiteral (freeVars (Unless (f,g)))
839
- and (iP1,uP1,sP1,eP1) = dsnf f
840
- and (iP2,uP2,sP2,eP2) = dsnf g
838
+ and (iP1,uP1,sP1,eP1) = dsnf ~use FOrenaming f
839
+ and (iP2,uP2,sP2,eP2) = dsnf ~use FOrenaming g
841
840
in setSeen (Unless (f,g)) newP ;
842
841
(newP,
843
842
(
0 commit comments