generate(mutation(Expression:prob_ast_seq_expr),NewExpression) :-
\+is_list(Expression) ,
random_seq_expr_mutation(Expression,NewExpression).
generate(mutation(Expressions:prob_ast_seq_expr),NewExpression) :-
maplist(random_seq_expr_mutation,Expressions,Mutated) ,
concatenate_ast(Mutated,[concat],NewExpression).
generate(mutation(avl_set(Seq):prob_value_seq),avl_set(Value)) :-
avl_to_list(Seq,AVLList) ,
% remove indices to generate new ones after mutation
% to get well-definedness
findall(Key,member(Key-_,AVLList),Temp) ,
seq_to_list(Temp,SeqValues) ,
random_permutation(SeqValues,Permutation) ,
gen_indexed_couple_list(1,Permutation,CoupleList) ,
findall(Key-true,member(Key,CoupleList),ValueAVL) ,
list_to_avl(ValueAVL,Value).
generate(mutation([H|ListOfSeq]:prob_value_seq),avl_set(Value)) :-
H = avl_set(_) ,
findall(Tree,member(avl_set(Tree),[H|ListOfSeq]),Seq) ,
maplist(avl_to_list,Seq,Temp) ,
maplist(avl_list_to_list,Temp,Temp2) ,
maplist(seq_to_list,Temp2,List) ,
flatten(List,SeqValues) ,
random_permutation(SeqValues,Permutation) ,
gen_indexed_couple_list(1,Permutation,CoupleList) ,
findall(Key-true,member(Key,CoupleList),ValueAVL) ,
list_to_avl(ValueAVL,Value).
generate(mutation(Seq:prob_value_seq),Value) :-
flattened(Seq) ,
seq_to_list(Seq,SeqValues) ,
random_permutation(SeqValues,Permutation) ,
gen_indexed_couple_list(1,Permutation,Value).
generate(mutation(ListOfSeq:prob_value_seq),Value) :-
maplist(seq_to_list,ListOfSeq,Temp) ,
flatten(Temp,SeqValues) ,
random_permutation(SeqValues,Permutation) ,
gen_indexed_couple_list(1,Permutation,Value).