Its always possible to create an auxiliary predicate whose purpose is to do the case analysis and return a result to a caller, whereby the caller only gets a list returned of, say, 4 or 5, but for its further processing only cares that its a list and not about length.
E.g.
aux_predicate(X, Ls) :-
X =4,
process_4(X, Ls). % returns Ls that is four
aux_predicate(X, Ls) :-
X =5,
process_5(X, Ls). % returns Ls that is five
predicate(X) :-
aux_predicate(X, Ls), % takes care of case analysis
process(X, Ls).
Edit:
I think i now understand what you are saying – you need to have a constraint that is parameterized by the aircraft type that is then used to determine the needed number of crew members per aircraft type.
I think this also can be done via an auxiliary predciate for testing – the case analysis can be consolidated into a parameter – the aircraft type
% UNTESTED CODE
group_type(Type, Group) :-
findall(P, employee(P, _, Type, _), Group).
% note how append is used in reverse to split an "appended" list into component lists
alloc_2(P1-S1-Pr1, P2-S2-Pr2) :-
group_type(pilot, Pilots),
group_type(steward, Stewards),
group_type(pursuer, Pursuers),
append(P1, P2, Pilots),
append(S1, S2, Stewards),
append(Pr1, Pr2, Pursuers).
% constraints cabin crew size which is defined as number of pilots and steward/esses.
test_cabin_crew_size(AircraftType, P, S) :-
flotte(_,_, AircraftType, CabinCrewSize),
length(P, P_N),
length(S, S_N),
Total is P_N + S_N,
CabinCrewSize = Total.
generate_and_test :-
alloc_2(P1-S1-Pr1, P2-S2-Pr2), % generate allocation
test_cabin_crew_size(a300_300, P1, S1) , % only accept fitting crew size for aircraft type
test_cabin_crew_size(crj_900, P2, S2) , % ditto
...
The nice thing above is, again, that you simply specify the generator, and then how each generated example is tested, and backtracking ensures you go through all generated examples and get them tested.
This is, again, however, an example where the number of aircraft types is fixed in the code to example 2, and those two in the table – you need to find a way to generalize that to any number of aircraft types, and any kind of routing planning and aircraft allocation per day.