let is_schema_term (term: term) : bool =
  let terms =
    match term with
      | Func func -> func.subterms
      | _ -> [| |]
  in
    try
      ignore (
        Array.fold_left
          (fun acc term ->
             match term with
               | Var var ->
                   (* check that this variable has not been used before.*)
                   if List.exists (fun old_var -> Var.equal var old_var) acc then
                     raise Exit
                   else
                     var :: acc
                         
               | _ ->
                   (* must be a variable *)
                   raise Exit
          )
          []
          terms
      );
      true
    with
      | Exit ->
          false