-- For your main program which will call functions from the modules.

--os.execute("clear")
Execute(MatchReplace(note,Nope),"Log beginning at " .. os.date() ,nil,true)

Execute(MatchReplace(printnote,Nope),"Loading function name map.")
Execute(ApplyTemplateToTable,_G,MatchReplace(FunctionNameMap,{}))

math.randomseed(os.time())

local function GenerateID()
	return tostring(math.random()*10^14)
end

local function GenerateUniqueID(intplt)
	local id = GenerateID()
	while LookupItemInTemplate(id,intplt) do
		id = GenerateID()
	end
	return id
end

local function IsConsistentToBool(inval,checktbl)
	for entry=1,TableLength(checktbl) do
		if NotToBool(ExecuteFromTemplate(checktbl,inval)) then
			return false
		end
	end
	return true
end

local function IsTableConsistentToBool(intbl,checktbl)
	if TableLength(intbl) <= TableLength(checktbl) then
		for entry=1, TableLength(intbl) do
			if NotToBool(IsConsistentToBool(checktbl[entry],intbl[entry])) then
				return false,intbl,checktbl
			end
		end
	end
	return true,intbl,checktbl
end

local function IsDatalogicConsistentToBool(datalogic,checktbl)
	return IsTableConsistentToBool(TableFold(datalogic,1),checktbl)
end

local function IsDatalogicConvergentToBool(datalogic,checktbl,rangetbl)
	if NotToBool(IsDatalogicConsistentToBool(datalogictbl,checktbl)) then
		return false,datalogic,checktbl
	else
		local result = ValueUnpack(ListPack(ExecuteTable(datalogic)))
		if IsTableConsistentToBool(result,rangetbl) then
			return true,datalogic,checktbl,result,rangetbl
		else
			return false,result,rangetbl
		end
	end
end
