(* Compar.nb ------------------------------------------------------------ *)

(* Compares two files of posets specified by the user. *)

(* Function Needed: StdFormIso[]. *)

(* User must specify the directory, two input families, and poset size. *)

(* Change Directory: *)        
SetDirectory["G:/.isis/home/c/a/cagann/public_html/Posets"]; 

<< GenrlUtils.m;    << PosetUtils.m;    << InvExIsoFncts.m;

(* Change both input families: *) fam1 = "ThrStds/thrstds";
                                  fam2 = "StdPsts/stdpsts";

(* Change poset size: *)          nc = 7;


(* Input files are read in and their lengths displayed. *)
infl1 = ReadList[StringJoin[fam1,ToString[nc]]];
infl2 = ReadList[StringJoin[fam2,ToString[nc]]];
intrsectn = Intersection[infl1,infl2];
Print[StringJoin["Number of Posets in File 1: ", ToString[Length[infl1]]]];
Print[StringJoin["Number of Posets in File 2: ", ToString[Length[infl2]]]];
Print[StringJoin[
	"Number of Posets in Both Files: ", ToString[Length[intrsectn]]
]];


relfnd = False;
(* Relationship between original files is determined. *)
Which[
	Length[infl1] < Length[infl2] && intrsectn\[Equal]Sort[infl1],
	relfnd = True;
	Print["File 1 is a proper subset of File 2."],
	
	Length[infl1] > Length[infl2] && intrsectn\[Equal]Sort[infl2],
	relfnd = True;
	Print["File 2 is a proper subset of File 1."],

	Length[infl1]\[Equal]Length[infl2] && infl1\[Equal]infl2,
	relfnd = True;
	Print["The files are identical."],

	Length[infl1]\[Equal]Length[infl2] && Sort[infl1]\[Equal]Sort[infl2],
	relfnd = True;
	Print["The files are identical after sorting."]
];


(* If a relationship hasn't been found, find the standard form of all elts
	in infl2 and compare this list to infl1. *)
If[ !relfnd,
	stdfl2 = Sort[Map[StdFormIso[#][[1]]&,infl2]];
	stdintrsct = Intersection[infl1,stdfl2];
	Print[StringJoin[
		"Number of Standard Forms of Posets in File 2 which are in File 1: ",
		ToString[Length[stdintrsct]]
	]]; 

	Which[
		Length[infl1]<Length[infl2] && stdintrsct\[Equal]Sort[infl1],
		Print["File 1 is a proper subset of the list of standard forms of"];
		Print["the posets in File 2."],

		Length[infl1]>Length[infl2] && stdintrsct\[Equal]stdfl2,
		Print["The standard forms of the posets in File 2 are a"]; 
		Print["proper subset of File 1."],

		Length[infl1]\[Equal]Length[infl2] && Sort[infl1]\[Equal]stdfl2,
		Print["The sorted list of standard forms of the posets in File 2"];
		Print["is identical to the sorted version of File 1."],

		True,
		Print["There is no simple relationship between these files."]
	]
]

(* End of Compar.m. *)