schema_vars(sref(Name,Deco,_,Renamings),Env,Vars) :-
zlookup_schema(Env,Name,_,Expr),
schema_vars(Expr,Env,Vars1),
decorate_vars(Vars1,Deco,DVars),
rename(DVars,Renamings,Vars).
schema_vars(sand(A,B),Env,Vars) :- schema_vars_logbin(A,B,Env,Vars).
schema_vars(sor(A,B),Env,Vars) :- schema_vars_logbin(A,B,Env,Vars).
schema_vars(simplies(A,B),Env,Vars) :- schema_vars_logbin(A,B,Env,Vars).
schema_vars(sequiv(A,B),Env,Vars) :- schema_vars_logbin(A,B,Env,Vars).
schema_vars(snot(A),Env,Vars) :- schema_vars(A,Env,Vars).
schema_vars(sforall(B,S),Env,Vars) :- schema_vars_quantifier(B,S,Env,Vars).
schema_vars(sexists(B,S),Env,Vars) :- schema_vars_quantifier(B,S,Env,Vars).
schema_vars(sexists1(B,S),Env,Vars) :- schema_vars_quantifier(B,S,Env,Vars).
schema_vars(hide(S,Hide),Env,Vars) :-
schema_vars(S,Env,All),remove_all(All,Hide,Vars).
schema_vars(fatsemi(A,B),Env,Vars) :-
schema_vars(A,Env,AVars),
findall(name(Name,'\''),member(name(Name,'\''),AVars),InterA),
remove_all(AVars,InterA,Aall),
schema_vars(B,Env,BVars),
findall(name(Name,''),member(name(Name,''),BVars),InterB),
remove_all(BVars,InterB,Ball),
append_not_duplicate(Aall,Ball,Vars).
schema_vars(project(_,B),Env,Vars) :- schema_vars(B,Env,Vars).
schema_vars(pre(Schema),Env,Vars) :-
schema_vars(Schema,Env,AllVars),
findall(name(Name,Deco),
(member(name(Name,Deco),AllVars), \+ member(Deco,['\'','!'])),
Vars).
schema_vars(pipe(A,B),Env,Vars) :-
schema_vars(A,Env,AVars),
schema_vars(B,Env,BVars),
findall(name(Name,'!'),
(member(name(Name,'!'),AVars),member(name(Name,'?'),BVars)),
Out),
findall(name(Name,'?'),member(name(Name,'!'),Out),In),
remove_all(AVars,Out,AwoO),
remove_all(BVars,In,BwoI),
append_not_duplicate(AwoO,BwoI,Vars).
schema_vars(text(Body),Env,Vars) :- schema_vars(Body,Env,Vars).
schema_vars(body(Decl,_),Env,Vars) :- schema_vars_decl(Decl,Env,Vars).