diff --git a/src/Conjure/UI/Model.hs b/src/Conjure/UI/Model.hs index d4414e1f13..cde17fcd4b 100644 --- a/src/Conjure/UI/Model.hs +++ b/src/Conjure/UI/Model.hs @@ -1938,14 +1938,7 @@ rule_DotLtLeq = "generic-DotLtLeq" `namedRule` theRule where rule_Flatten_Lex :: Rule rule_Flatten_Lex = "flatten-lex" `namedRule` theRule where theRule [essence| &a - na "rule_Flatten_Lex" - (TypeMatrix TypeInt{} TypeInt{}, TypeMatrix TypeInt{} TypeInt{}) -> - na "rule_Flatten_Lex" - _ -> return () + reject_flat a b fa <- flatten a fb <- flatten b tfa <- typeOf fa @@ -1958,14 +1951,7 @@ rule_Flatten_Lex = "flatten-lex" `namedRule` theRule where , return [essence| &fa - na "rule_Flatten_Lex" - (TypeMatrix TypeInt{} TypeInt{}, TypeMatrix TypeInt{} TypeInt{}) -> - na "rule_Flatten_Lex" - _ -> return () + reject_flat a b fa <- flatten a fb <- flatten b tfa <- typeOf fa @@ -1978,6 +1964,24 @@ rule_Flatten_Lex = "flatten-lex" `namedRule` theRule where , return [essence| &fa <=lex &fb |] ) theRule _ = na "rule_Flatten_Lex" + reject_flat a b = do + ta <- typeOf a + tb <- typeOf b + case (ta, tb) of + (TypeMatrix TypeBool TypeInt{}, _) -> + na "rule_Flatten_Lex" + (TypeMatrix TypeBool TypeBool, _) -> + na "rule_Flatten_Lex" + (TypeList TypeInt{}, _) -> + na "rule_Flatten_Lex" + (TypeMatrix TypeInt{} TypeInt{}, _) -> + na "rule_Flatten_Lex" + (TypeList TypeBool, _) -> + na "rule_Flatten_Lex" + (TypeMatrix TypeInt{} TypeBool, _) -> + na "rule_Flatten_Lex" + _ -> return () + flatten a = do ta <- typeOf a case ta of diff --git a/tests/custom/flatten_lex/matrix_2_bools/matrix.essence b/tests/custom/flatten_lex/find_v_find/matrix_2_bools/matrix.essence similarity index 100% rename from tests/custom/flatten_lex/matrix_2_bools/matrix.essence rename to tests/custom/flatten_lex/find_v_find/matrix_2_bools/matrix.essence diff --git a/tests/custom/flatten_lex/matrix_2_bools/run.sh b/tests/custom/flatten_lex/find_v_find/matrix_2_bools/run.sh similarity index 100% rename from tests/custom/flatten_lex/matrix_2_bools/run.sh rename to tests/custom/flatten_lex/find_v_find/matrix_2_bools/run.sh diff --git a/tests/custom/flatten_lex/matrix_2_bools/stdout.expected b/tests/custom/flatten_lex/find_v_find/matrix_2_bools/stdout.expected similarity index 100% rename from tests/custom/flatten_lex/matrix_2_bools/stdout.expected rename to tests/custom/flatten_lex/find_v_find/matrix_2_bools/stdout.expected diff --git a/tests/custom/flatten_lex/matrix_2_mixed/matrix.essence b/tests/custom/flatten_lex/find_v_find/matrix_2_mixed/matrix.essence similarity index 100% rename from tests/custom/flatten_lex/matrix_2_mixed/matrix.essence rename to tests/custom/flatten_lex/find_v_find/matrix_2_mixed/matrix.essence diff --git a/tests/custom/flatten_lex/matrix_2_mixed/run.sh b/tests/custom/flatten_lex/find_v_find/matrix_2_mixed/run.sh similarity index 100% rename from tests/custom/flatten_lex/matrix_2_mixed/run.sh rename to tests/custom/flatten_lex/find_v_find/matrix_2_mixed/run.sh diff --git a/tests/custom/flatten_lex/matrix_2_mixed/stdout.expected b/tests/custom/flatten_lex/find_v_find/matrix_2_mixed/stdout.expected similarity index 100% rename from tests/custom/flatten_lex/matrix_2_mixed/stdout.expected rename to tests/custom/flatten_lex/find_v_find/matrix_2_mixed/stdout.expected diff --git a/tests/custom/flatten_lex/matrix_of_matrix/matrix.essence b/tests/custom/flatten_lex/find_v_find/matrix_of_matrix/matrix.essence similarity index 100% rename from tests/custom/flatten_lex/matrix_of_matrix/matrix.essence rename to tests/custom/flatten_lex/find_v_find/matrix_of_matrix/matrix.essence diff --git a/tests/custom/flatten_lex/matrix_of_matrix/run.sh b/tests/custom/flatten_lex/find_v_find/matrix_of_matrix/run.sh similarity index 100% rename from tests/custom/flatten_lex/matrix_of_matrix/run.sh rename to tests/custom/flatten_lex/find_v_find/matrix_of_matrix/run.sh diff --git a/tests/custom/flatten_lex/matrix_of_matrix/stdout.expected b/tests/custom/flatten_lex/find_v_find/matrix_of_matrix/stdout.expected similarity index 100% rename from tests/custom/flatten_lex/matrix_of_matrix/stdout.expected rename to tests/custom/flatten_lex/find_v_find/matrix_of_matrix/stdout.expected diff --git a/tests/custom/flatten_lex/tuple_2_bools/run.sh b/tests/custom/flatten_lex/find_v_find/tuple_2_bools/run.sh similarity index 100% rename from tests/custom/flatten_lex/tuple_2_bools/run.sh rename to tests/custom/flatten_lex/find_v_find/tuple_2_bools/run.sh diff --git a/tests/custom/flatten_lex/tuple_2_bools/stdout.expected b/tests/custom/flatten_lex/find_v_find/tuple_2_bools/stdout.expected similarity index 100% rename from tests/custom/flatten_lex/tuple_2_bools/stdout.expected rename to tests/custom/flatten_lex/find_v_find/tuple_2_bools/stdout.expected diff --git a/tests/custom/flatten_lex/tuple_2_bools/tuple.essence b/tests/custom/flatten_lex/find_v_find/tuple_2_bools/tuple.essence similarity index 100% rename from tests/custom/flatten_lex/tuple_2_bools/tuple.essence rename to tests/custom/flatten_lex/find_v_find/tuple_2_bools/tuple.essence diff --git a/tests/custom/flatten_lex/tuple_3_bool_boolmat_int/run.sh b/tests/custom/flatten_lex/find_v_find/tuple_3_bool_boolmat_int/run.sh similarity index 100% rename from tests/custom/flatten_lex/tuple_3_bool_boolmat_int/run.sh rename to tests/custom/flatten_lex/find_v_find/tuple_3_bool_boolmat_int/run.sh diff --git a/tests/custom/flatten_lex/tuple_3_bool_boolmat_int/stdout.expected b/tests/custom/flatten_lex/find_v_find/tuple_3_bool_boolmat_int/stdout.expected similarity index 100% rename from tests/custom/flatten_lex/tuple_3_bool_boolmat_int/stdout.expected rename to tests/custom/flatten_lex/find_v_find/tuple_3_bool_boolmat_int/stdout.expected diff --git a/tests/custom/flatten_lex/tuple_3_bool_boolmat_int/tuple.essence b/tests/custom/flatten_lex/find_v_find/tuple_3_bool_boolmat_int/tuple.essence similarity index 100% rename from tests/custom/flatten_lex/tuple_3_bool_boolmat_int/tuple.essence rename to tests/custom/flatten_lex/find_v_find/tuple_3_bool_boolmat_int/tuple.essence diff --git a/tests/custom/flatten_lex/tuple_3_bools/run.sh b/tests/custom/flatten_lex/find_v_find/tuple_3_bools/run.sh similarity index 100% rename from tests/custom/flatten_lex/tuple_3_bools/run.sh rename to tests/custom/flatten_lex/find_v_find/tuple_3_bools/run.sh diff --git a/tests/custom/flatten_lex/tuple_3_bools/stdout.expected b/tests/custom/flatten_lex/find_v_find/tuple_3_bools/stdout.expected similarity index 100% rename from tests/custom/flatten_lex/tuple_3_bools/stdout.expected rename to tests/custom/flatten_lex/find_v_find/tuple_3_bools/stdout.expected diff --git a/tests/custom/flatten_lex/tuple_3_bools/tuple.essence b/tests/custom/flatten_lex/find_v_find/tuple_3_bools/tuple.essence similarity index 100% rename from tests/custom/flatten_lex/tuple_3_bools/tuple.essence rename to tests/custom/flatten_lex/find_v_find/tuple_3_bools/tuple.essence diff --git a/tests/custom/flatten_lex/tuple_3_bools_and_ints/run.sh b/tests/custom/flatten_lex/find_v_find/tuple_3_bools_and_ints/run.sh similarity index 100% rename from tests/custom/flatten_lex/tuple_3_bools_and_ints/run.sh rename to tests/custom/flatten_lex/find_v_find/tuple_3_bools_and_ints/run.sh diff --git a/tests/custom/flatten_lex/tuple_3_bools_and_ints/stdout.expected b/tests/custom/flatten_lex/find_v_find/tuple_3_bools_and_ints/stdout.expected similarity index 100% rename from tests/custom/flatten_lex/tuple_3_bools_and_ints/stdout.expected rename to tests/custom/flatten_lex/find_v_find/tuple_3_bools_and_ints/stdout.expected diff --git a/tests/custom/flatten_lex/tuple_3_bools_and_ints/tuple.essence b/tests/custom/flatten_lex/find_v_find/tuple_3_bools_and_ints/tuple.essence similarity index 100% rename from tests/custom/flatten_lex/tuple_3_bools_and_ints/tuple.essence rename to tests/custom/flatten_lex/find_v_find/tuple_3_bools_and_ints/tuple.essence diff --git a/tests/custom/flatten_lex/tuple_of_matrices_and_tuples/run.sh b/tests/custom/flatten_lex/find_v_find/tuple_of_matrices_and_tuples/run.sh similarity index 100% rename from tests/custom/flatten_lex/tuple_of_matrices_and_tuples/run.sh rename to tests/custom/flatten_lex/find_v_find/tuple_of_matrices_and_tuples/run.sh diff --git a/tests/custom/flatten_lex/tuple_of_matrices_and_tuples/stdout.expected b/tests/custom/flatten_lex/find_v_find/tuple_of_matrices_and_tuples/stdout.expected similarity index 100% rename from tests/custom/flatten_lex/tuple_of_matrices_and_tuples/stdout.expected rename to tests/custom/flatten_lex/find_v_find/tuple_of_matrices_and_tuples/stdout.expected diff --git a/tests/custom/flatten_lex/tuple_of_matrices_and_tuples/tuple.essence b/tests/custom/flatten_lex/find_v_find/tuple_of_matrices_and_tuples/tuple.essence similarity index 100% rename from tests/custom/flatten_lex/tuple_of_matrices_and_tuples/tuple.essence rename to tests/custom/flatten_lex/find_v_find/tuple_of_matrices_and_tuples/tuple.essence diff --git a/tests/custom/flatten_lex/tuple_of_tuples/run.sh b/tests/custom/flatten_lex/find_v_find/tuple_of_tuples/run.sh similarity index 100% rename from tests/custom/flatten_lex/tuple_of_tuples/run.sh rename to tests/custom/flatten_lex/find_v_find/tuple_of_tuples/run.sh diff --git a/tests/custom/flatten_lex/tuple_of_tuples/stdout.expected b/tests/custom/flatten_lex/find_v_find/tuple_of_tuples/stdout.expected similarity index 100% rename from tests/custom/flatten_lex/tuple_of_tuples/stdout.expected rename to tests/custom/flatten_lex/find_v_find/tuple_of_tuples/stdout.expected diff --git a/tests/custom/flatten_lex/tuple_of_tuples/tuple.essence b/tests/custom/flatten_lex/find_v_find/tuple_of_tuples/tuple.essence similarity index 100% rename from tests/custom/flatten_lex/tuple_of_tuples/tuple.essence rename to tests/custom/flatten_lex/find_v_find/tuple_of_tuples/tuple.essence diff --git a/tests/custom/flatten_lex/find_v_given/matrix_2_bools/matrix.essence b/tests/custom/flatten_lex/find_v_given/matrix_2_bools/matrix.essence new file mode 100644 index 0000000000..575e8ff9b5 --- /dev/null +++ b/tests/custom/flatten_lex/find_v_given/matrix_2_bools/matrix.essence @@ -0,0 +1,3 @@ +given A : matrix indexed by [int(0..1)] of (bool,bool) +find B : matrix indexed by [int(0..1)] of (bool,bool) +such that A .< B diff --git a/tests/custom/flatten_lex/find_v_given/matrix_2_bools/matrix.param b/tests/custom/flatten_lex/find_v_given/matrix_2_bools/matrix.param new file mode 100644 index 0000000000..881e32d0e1 --- /dev/null +++ b/tests/custom/flatten_lex/find_v_given/matrix_2_bools/matrix.param @@ -0,0 +1 @@ +letting A be [(true,false),(false,true);int(0..1)] diff --git a/tests/custom/flatten_lex/find_v_given/matrix_2_bools/run.sh b/tests/custom/flatten_lex/find_v_given/matrix_2_bools/run.sh new file mode 100755 index 0000000000..cd5a0a4091 --- /dev/null +++ b/tests/custom/flatten_lex/find_v_given/matrix_2_bools/run.sh @@ -0,0 +1,5 @@ +conjure solve *.essence *.param +cat conjure-output/*.eprime +cat *.solution +rm *.solution +rm -r conjure-output diff --git a/tests/custom/flatten_lex/find_v_given/matrix_2_bools/stdout.expected b/tests/custom/flatten_lex/find_v_given/matrix_2_bools/stdout.expected new file mode 100644 index 0000000000..2bb1e55bbd --- /dev/null +++ b/tests/custom/flatten_lex/find_v_given/matrix_2_bools/stdout.expected @@ -0,0 +1,92 @@ +Generating models for matrix.essence +Generated models: model000001.eprime +Saved under: conjure-output +Savile Row: model000001.eprime matrix.param +Running minion for domain filtering. +Running solver: minion +Copying solution to: matrix-matrix.solution +language ESSENCE' 1.0 + +given A_1: matrix indexed by [int(0..1)] of bool +given A_2: matrix indexed by [int(0..1)] of bool +find B_1: matrix indexed by [int(0..1)] of bool +find B_2: matrix indexed by [int(0..1)] of bool +branching on [B_1, B_2] +such that + flatten([flatten([[-toInt(A_1[q2]); int(1)], [-toInt(A_2[q2]); int(1)]; int(1..2)]) | q2 : int(0..1)])