# history

source:
  import islpy as isl
  from islplot.plotter import *
  from islplot.plotter3d import plot_set_3d
  from IPython.display import HTML

source_raw:
  import islpy as isl
  from islplot.plotter import *
  from islplot.plotter3d import plot_set_3d
  from IPython.display import HTML


source:
  get_ipython().run_cell_magic('script', 'echo Nothing to execute here. This code is merely a copy of the example code in the handout.', '# %%  *** Example SCoP: 1 *** \n    \nfor (int i = 0; i <= n; ++i){\n    for (int j = 0; j <= 3; ++j)\n    S: B[i] = B[i] + A[j];\n}\n\n%%  *** Example SCoP: 2 ***\n\nfor (int i = 0; i <= 3; ++i){\n    for (int j = 0; j <= 3; ++j)\n    S: C[i][j] = beta * C[i][j];\n    \n    for (int k = 0; k <= 3; ++k)\n        for (int j = 0; j <= 3; ++j)\n        T: C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j] ;\n}\n')

source_raw:
  %%script echo Nothing to execute here. This code is merely a copy of the example code in the handout.
  # %%  *** Example SCoP: 1 *** 
      
  for (int i = 0; i <= n; ++i){
      for (int j = 0; j <= 3; ++j)
      S: B[i] = B[i] + A[j];
  }

  %%  *** Example SCoP: 2 ***

  for (int i = 0; i <= 3; ++i){
      for (int j = 0; j <= 3; ++j)
      S: C[i][j] = beta * C[i][j];
      
      for (int k = 0; k <= 3; ++k)
          for (int j = 0; j <= 3; ++j)
          T: C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j] ;
  }


source_raw:
  %pylab inline
  # Load islpy and islplot
  import islpy as isl
  from islplot.plotter import *

source:
  get_ipython().run_line_magic('pylab', 'inline')
  # Load islpy and islplot
  import islpy as isl
  from islplot.plotter import *


source:
  s2_D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  s2_D_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= k <= 3 and 0 <= j <= 3}")
  domain = isl.UnionSet("{}")
  domain = domain.union(s2_D_S).union(s2_D_T)
  print(domain)

source_raw:
  s2_D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  s2_D_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= k <= 3 and 0 <= j <= 3}")
  domain = isl.UnionSet("{}")
  domain = domain.union(s2_D_S).union(s2_D_T)
  print(domain)


source:
  plot_set_points(s2_D_S, marker="o")
  #plot_set_points(Set("{S[x,y]: 0 <= x <= 8 and -7 <= y <= 5}"), marker=".", color="gray", size=3)

source_raw:
  plot_set_points(s2_D_S, marker="o")
  #plot_set_points(Set("{S[x,y]: 0 <= x <= 8 and -7 <= y <= 5}"), marker=".", color="gray", size=3)


source:
  for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;

  for (i = 0; i < 5; i++)
  for (j=0; j < i; j++)
  S: A[j] = 0;
  for (i = 0; i < N; i += 2)
  for (j = 0; j < i; j++)
  S: A[j] = 0;

source_raw:
  for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;

  for (i = 0; i < 5; i++)
  for (j=0; j < i; j++)
  S: A[j] = 0;
  for (i = 0; i < N; i += 2)
  for (j = 0; j < i; j++)
  S: A[j] = 0;


source:
  fixer = isl.Set("[n] -> {S[i,j]: n = 3}")
  s1_D_S = s1_D_S.intersect(fixer)
  plot_set_points(s1_D_S, marker = ".")

source_raw:
  fixer = isl.Set("[n] -> {S[i,j]: n = 3}")
  s1_D_S = s1_D_S.intersect(fixer)
  plot_set_points(s1_D_S, marker = ".")


source:
  # a
  for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 2 and 0 <= j <= i}")
  print(t_D_c_S)

source_raw:
  # a
  for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 2 and 0 <= j <= i}")
  print(t_D_c_S)


source:
  get_ipython().run_cell_magic('', '', '# a\nfor (i = 0; i < 5; i++)\n    for (j = 0; j < 5; j++)\nS:      A[i + 3*j] = alpha * K;\nt_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")\nprint(t_D_a_S)\n\n# b\nfor (i = 0; i < 5; i++)\n    for (j=0; j < i; j++)\nS:      A[j] = 0;\nt_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")\nprint(t_D_b_S)\n\n# c    \nfor (i = 0; i < N; i += 2)\n    for (j = 0; j < i; j++)\nS:      A[j] = 0;\nt_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 2 and 0 <= j <= i}")\nprint(t_D_c_S)\n')

source_raw:
  %%
  # a
  for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 2 and 0 <= j <= i}")
  print(t_D_c_S)


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 2 and 0 <= j <= i}")
  print(t_D_c_S)

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 2 and 0 <= j <= i}")
  print(t_D_c_S)


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 2 and 0 <= j <= i}")
  print(t_D_c_S)

  plot_set_points(t_D_a_S, marker="o")

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 2 and 0 <= j <= i}")
  print(t_D_c_S)

  plot_set_points(t_D_a_S, marker="o")


source:
  fixer = isl.Set("[alpha, K] -> {S[i,j]: alpha = 3 and K= 5}")
  t_D_b_S = t_D_b_S.intersect(fixer)
  plot_set_points(t_D_b_S, marker = ".")

source_raw:
  fixer = isl.Set("[alpha, K] -> {S[i,j]: alpha = 3 and K= 5}")
  t_D_b_S = t_D_b_S.intersect(fixer)
  plot_set_points(t_D_b_S, marker = ".")


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i mod 2 = 2 and 0 <= j <= i}")
  print(t_D_c_S)

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i mod 2 = 2 and 0 <= j <= i}")
  print(t_D_c_S)


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 == 2 and 0 <= j <= i}")
  print(t_D_c_S)

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 == 2 and 0 <= j <= i}")
  print(t_D_c_S)


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 0 and 0 <= j <= i}")
  print(t_D_c_S)

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("[alpha, K] -> {S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 0 and 0 <= j <= i}")
  print(t_D_c_S)


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 0 and 0 <= j <= i}")
  print(t_D_c_S)

  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  t_D_d_S = isl.Set("[M] -> {S[i,j]: 0 <= i <= M and i > M and 0 <= j <= i}")
  print(t_D_d_S)

  # e
  for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;
  t_D_e_S = isl.Set("[M] -> {S[i,j]: 0 <= i <= M and 0 <= j <= i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 0 and 0 <= j <= i}")
  print(t_D_c_S)

  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  t_D_d_S = isl.Set("[M] -> {S[i,j]: 0 <= i <= M and i > M and 0 <= j <= i}")
  print(t_D_d_S)

  # e
  for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;
  t_D_e_S = isl.Set("[M] -> {S[i,j]: 0 <= i <= M and 0 <= j <= i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 0 and 0 <= j <= i}")
  print(t_D_c_S)

  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  t_D_d_S = isl.Set("[M] -> {S[i,j]: 0 <= i <= M and i > M and 0 <= j <= i}")
  print(t_D_d_S)

  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[M] -> {S[i,j]: 0 <= i <= M and 0 <= j <= i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i <= 5 and 0 <= j <= i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i <= N and i % 2 = 0 and 0 <= j <= i}")
  print(t_D_c_S)

  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  t_D_d_S = isl.Set("[M] -> {S[i,j]: 0 <= i <= M and i > M and 0 <= j <= i}")
  print(t_D_d_S)

  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[M] -> {S[i,j]: 0 <= i <= M and 0 <= j <= i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(t_D_c_S)

  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  t_D_d_S = isl.Set("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(t_D_d_S)

  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(t_D_a_S)

  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < i}")
  print(t_D_b_S)

  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(t_D_c_S)

  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  t_D_d_S = isl.Set("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(t_D_d_S)

  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)


source:
  fixer = isl.Set("[N] -> {S[i,j]: N = 3}")
  t_D_c_S = t_D_c_S.intersect(fixer)
  plot_set_points(t_D_c_S, marker = ".")

source_raw:
  fixer = isl.Set("[N] -> {S[i,j]: N = 3}")
  t_D_c_S = t_D_c_S.intersect(fixer)
  plot_set_points(t_D_c_S, marker = ".")


source:
  fixer = isl.Set("[N] -> {S[i,j]: N = 3}")
  t_D_c_S = t_D_c_S.intersect(fixer)
  plot_set_points(t_D_c_S, marker = "R")

source_raw:
  fixer = isl.Set("[N] -> {S[i,j]: N = 3}")
  t_D_c_S = t_D_c_S.intersect(fixer)
  plot_set_points(t_D_c_S, marker = "R")


source:
  fixer = isl.Set("[N] -> {S[i,j]: N = 3}")
  t_D_c_S = t_D_c_S.intersect(fixer)
  plot_set_points(t_D_c_S, marker = "o")

source_raw:
  fixer = isl.Set("[N] -> {S[i,j]: N = 3}")
  t_D_c_S = t_D_c_S.intersect(fixer)
  plot_set_points(t_D_c_S, marker = "o")


source:
  get_ipython().run_line_magic('pylab', 'inline')
  # Load islpy and islplot
  import islpy as isl
  from islplot.plotter import *
  from islplot.plotter3d import plot_set_3d
  from IPython.display import HTML

source_raw:
  %pylab inline
  # Load islpy and islplot
  import islpy as isl
  from islplot.plotter import *
  from islplot.plotter3d import plot_set_3d
  from IPython.display import HTML


source:
  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < i}")
  print(t_D_b_S)

source_raw:
  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_b_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < i}")
  print(t_D_b_S)


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(t_D_a_S)

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(t_D_a_S)


source:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(t_D_c_S)

source_raw:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  t_D_c_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(t_D_c_S)


source:
  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  t_D_d_S = isl.Set("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(t_D_d_S)

source_raw:
  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  t_D_d_S = isl.Set("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(t_D_d_S)


source:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

source_raw:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)


source:
  # a
  for (i = 0; i < 5; i++){
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;
  }
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(t_D_a_S)

source_raw:
  # a
  for (i = 0; i < 5; i++){
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;
  }
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(t_D_a_S)


source:
  # a
  for (int i = 0; i < 5; i++){
      for (int j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;
  }
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(t_D_a_S)

source_raw:
  # a
  for (int i = 0; i < 5; i++){
      for (int j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;
  }
  t_D_a_S = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(t_D_a_S)


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  s1 = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(s1)

  d = plot_set_3d(s1, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  s1 = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(s1)

  d = plot_set_3d(s1, show_points=True, show_vertices=True)
  HTML(d)


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  s1 = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(s1)

  plot_set_points(s1, marker = ".")

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  s1 = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(s1)

  plot_set_points(s1, marker = ".")


source:
  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  s2 = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < i}")
  print(s2)

  plot_set_points(s2, marker = ".")

source_raw:
  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  s2 = isl.Set("{S[i,j]: 0 <= i < 5 and 0 <= j < i}")
  print(s2)

  plot_set_points(s2, marker = ".")


source:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  s3 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(s3)

source_raw:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  s3 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(s3)


source:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  s3 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(s3)

  fixer = isl.Set("[N] -> {S[i,j]: n = 5}")
  s3 = s3.intersect(fixer)
  plot_set_points(s3, marker = ".")

source_raw:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  s3 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(s3)

  fixer = isl.Set("[N] -> {S[i,j]: n = 5}")
  s3 = s3.intersect(fixer)
  plot_set_points(s3, marker = ".")


source:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  s3 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(s3)

  fixer = isl.Set("[N] -> {S[i,j]: N = 5}")
  s3 = s3.intersect(fixer)
  plot_set_points(s3, marker = ".")

source_raw:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  s3 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(s3)

  fixer = isl.Set("[N] -> {S[i,j]: N = 5}")
  s3 = s3.intersect(fixer)
  plot_set_points(s3, marker = ".")


source:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  s3 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(s3)

  fixer = isl.Set("[N] -> {S[i,j]: N = 10}")
  s3 = s3.intersect(fixer)
  plot_set_points(s3, marker = ".")

source_raw:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  s3 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(s3)

  fixer = isl.Set("[N] -> {S[i,j]: N = 10}")
  s3 = s3.intersect(fixer)
  plot_set_points(s3, marker = ".")


source:
  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  s4 = isl.Set("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(s4)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 10, M = 12}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")

source_raw:
  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  s4 = isl.Set("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(s4)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 10, M = 12}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")


source:
  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  s4 = isl.Set("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(s4)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 10, M = 3}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")

source_raw:
  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  s4 = isl.Set("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(s4)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 10, M = 3}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")


source:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 10, M = 3}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")

source_raw:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 10, M = 3}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")


source:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 100, M = 3}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")

source_raw:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 100, M = 3}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")


source:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 100, M = 200}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")

source_raw:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 100, M = 200}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")


source:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 100, M = 0}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")

source_raw:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 100, M = 0}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")


source:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

  fixer = isl.Set("[N] -> {S[i,j]: N = 100}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")

source_raw:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  t_D_e_S = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(t_D_e_S)

  fixer = isl.Set("[N] -> {S[i,j]: N = 100}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")


source:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  s5 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(s5)

  fixer = isl.Set("[N] -> {S[i,j]: N = 100}")
  s5 = s5.intersect(fixer)
  plot_set_points(s5, marker = ".")

source_raw:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  s5 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(s5)

  fixer = isl.Set("[N] -> {S[i,j]: N = 100}")
  s5 = s5.intersect(fixer)
  plot_set_points(s5, marker = ".")


source:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  s5 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(s5)

  fixer = isl.Set("[N] -> {S[i,j]: N = 10}")
  s5 = s5.intersect(fixer)
  plot_set_points(s5, marker = ".")

source_raw:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  s5 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i and i % 2 = 0 && j % 2 = 0}")
  print(s5)

  fixer = isl.Set("[N] -> {S[i,j]: N = 10}")
  s5 = s5.intersect(fixer)
  plot_set_points(s5, marker = ".")


source:
  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  s4 = isl.Set("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(s4)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 10 and M = 3}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")

source_raw:
  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  s4 = isl.Set("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(s4)

  fixer = isl.Set("[N, M] -> {S[i,j]: N = 10 and M = 3}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")


source:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  s5_1 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i}")
  s5_2 = isl.Set("{S[i,j]: i % 2 = 0 and j % 2 = 0}")
  s5 = isl.UnionSet("{}").union(s5_1).union(s5_2)
  print(s5)

  fixer = isl.Set("[N] -> {S[i,j]: N = 10}")
  s5 = s5.intersect(fixer)
  plot_set_points(s5, marker = ".")

source_raw:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  s5_1 = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i}")
  s5_2 = isl.Set("{S[i,j]: i % 2 = 0 and j % 2 = 0}")
  s5 = isl.UnionSet("{}").union(s5_1).union(s5_2)
  print(s5)

  fixer = isl.Set("[N] -> {S[i,j]: N = 10}")
  s5 = s5.intersect(fixer)
  plot_set_points(s5, marker = ".")


source:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  s5 = isl.UnionSet("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i}")
  print(s5)

  fixer = isl.Set("[N] -> {S[i,j]: N = 10}")
  s5 = s5.intersect(fixer)
  plot_set_points(s5, marker = ".")

source_raw:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  s5 = isl.UnionSet("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i}")
  print(s5)

  fixer = isl.Set("[N] -> {S[i,j]: N = 10}")
  s5 = s5.intersect(fixer)
  plot_set_points(s5, marker = ".")


source:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  s5 = isl.UnionSet("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i}")
  print(s5)

  fixer = isl.UnionSet("[N] -> {S[i,j]: N = 10}")
  s5 = s5.intersect(fixer)
  plot_set_points(s5, marker = ".")

source_raw:
  # e
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
          if (i % 2 == 0 && j % 2 == 0)
  S:          A[i][j] = 0;"""
  s5 = isl.UnionSet("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < i}")
  print(s5)

  fixer = isl.UnionSet("[N] -> {S[i,j]: N = 10}")
  s5 = s5.intersect(fixer)
  plot_set_points(s5, marker = ".")


source:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  s1 = isl.UnionSet("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(s1)

  plot_set_points(s1, marker = ".")

source_raw:
  # a
  """for (i = 0; i < 5; i++)
      for (j = 0; j < 5; j++)
  S:      A[i + 3*j] = alpha * K;"""
  s1 = isl.UnionSet("{S[i,j]: 0 <= i < 5 and 0 <= j < 5}")
  print(s1)

  plot_set_points(s1, marker = ".")


source:
  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  s2 = isl.UnionSet("{S[i,j]: 0 <= i < 5 and 0 <= j < i}")
  print(s2)

  plot_set_points(s2, marker = ".")

source_raw:
  # b
  """for (i = 0; i < 5; i++)
      for (j=0; j < i; j++)
  S:      A[j] = 0;"""
  s2 = isl.UnionSet("{S[i,j]: 0 <= i < 5 and 0 <= j < i}")
  print(s2)

  plot_set_points(s2, marker = ".")


source:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  s3 = isl.UnionSet("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(s3)

  fixer = isl.UnionSet("[N] -> {S[i,j]: N = 10}")
  s3 = s3.intersect(fixer)
  plot_set_points(s3, marker = ".")

source_raw:
  # c    
  """for (i = 0; i < N; i += 2)
      for (j = 0; j < i; j++)
  S:      A[j] = 0;"""
  s3 = isl.UnionSet("[N] -> {S[i,j]: 0 <= i < N and i % 2 = 0 and 0 <= j < i}")
  print(s3)

  fixer = isl.UnionSet("[N] -> {S[i,j]: N = 10}")
  s3 = s3.intersect(fixer)
  plot_set_points(s3, marker = ".")


source:
  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  s4 = isl.UnionSet("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(s4)

  fixer = isl.UnionSet("[N, M] -> {S[i,j]: N = 10 and M = 3}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")

source_raw:
  # d
  """for (i = 0; i < N; i++)
      for (j = 0; j < i; j++)
          if (i > M)
  S:          A[j] = 0;"""
  s4 = isl.UnionSet("[N, M] -> {S[i,j]: 0 <= i < N and i > M and 0 <= j < i}")
  print(s4)

  fixer = isl.UnionSet("[N, M] -> {S[i,j]: N = 10 and M = 3}")
  s4 = s4.intersect(fixer)
  plot_set_points(s4, marker = ".")


source:
  plot_set = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s)

  d = plot_set_3d(plot_set, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s)

  d = plot_set_3d(plot_set, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i,j <= 3"})
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i,j <= 3"})
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i,j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i,j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i,j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i,j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i,j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i,j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  #plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  #plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = isl.Set(plot_set_S.union(plot_set_T))

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = isl.Set(plot_set_S.union(plot_set_T))

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set.as_set(), show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(plot_set.as_set(), show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(Set.from_union_set(plot_set), show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(Set.from_union_set(plot_set), show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(isl.Set.from_union_set(plot_set), show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)

  d = plot_set_3d(isl.Set.from_union_set(plot_set), show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(isl.Set.from_union_set(plot_set), show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(isl.Set.from_union_set(plot_set), show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(plot_set_t, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(plot_set_t, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.UnionSet("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,j,k]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,j,k]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(plot_set)

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)


source:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,j,k]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(isl.Set.from_union_set(plot_set))

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)

source_raw:
  plot_set_S = isl.UnionSet("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  plot_set_T = isl.Set("{T[i,j,k]: 0 <= i <= 3 and 0 <= j <= 3 and 0 <= k <= 3}")
  print(plot_set_S)
  print(plot_set_T)
  plot_set = plot_set_S.union(plot_set_T)
  print(isl.Set.from_union_set(plot_set))

  d = plot_set_3d(plot_set_T, show_points=True, show_vertices=True)
  HTML(d)


source:
  """for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }"""
  m1_u = isl.UnionMap("{S[i,j] -> [t0,t1]: t0 = i and t1 = j}")
  m1_v = isl.UnionMap("{S[i,j] -> [t0,t1]: t0 = j and t1 = i}")
  m1 = m1_u.union(m1_v)
  print(m1)

source_raw:
  """for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }"""
  m1_u = isl.UnionMap("{S[i,j] -> [t0,t1]: t0 = i and t1 = j}")
  m1_v = isl.UnionMap("{S[i,j] -> [t0,t1]: t0 = j and t1 = i}")
  m1 = m1_u.union(m1_v)
  print(m1)


source:
  get_ipython().run_cell_magic('script', 'echo Nothing to execute here. This code is merely a copy of the example code in the handout.', '# %%  *** Example SCoP *** \n    \nfor (int i = 0; i <= n; ++i){\n    for (int j = 0; j <= 3; ++j)\n    S: B[i] = B[i] + A[j];\n}\n')

source_raw:
  %%script echo Nothing to execute here. This code is merely a copy of the example code in the handout.
  # %%  *** Example SCoP *** 
      
  for (int i = 0; i <= n; ++i){
      for (int j = 0; j <= 3; ++j)
      S: B[i] = B[i] + A[j];
  }


source:
  """for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }"""
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1]: t0 = i and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1]: t0 = j and t1 = i}")
  m1 = m1_u.union(m1_v)
  print(m1)

source_raw:
  """for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }"""
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1]: t0 = i and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1]: t0 = j and t1 = i}")
  m1 = m1_u.union(m1_v)
  print(m1)


source:
  """for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }"""
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)

source_raw:
  """for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }"""
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)


source:
  """for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j) {
  S:      C[j] = T[i][j]
      }

      for(int j = 0; j <=3; ++j) {
  T:      A[i] += C[j]
      }
  }"""
  m2_s = isl.UnionMap("{S[i][j] -> [t0,t1]: t0 = i and t1 = j}")
  m2_t = isl.UnionMap("{T[i][j] -> [t0,t1]: t0 = i and t1 = j}")
  m2 = m2_s.union(m2_t)
  print(m2)

source_raw:
  """for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j) {
  S:      C[j] = T[i][j]
      }

      for(int j = 0; j <=3; ++j) {
  T:      A[i] += C[j]
      }
  }"""
  m2_s = isl.UnionMap("{S[i][j] -> [t0,t1]: t0 = i and t1 = j}")
  m2_t = isl.UnionMap("{T[i][j] -> [t0,t1]: t0 = i and t1 = j}")
  m2 = m2_s.union(m2_t)
  print(m2)


source:
  """for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }"""
  m1_u = isl.UnionMap("[k] -> {U[i,j] -> [t0,t1,t2]: t0 = i and t1 = j and t2 = k}")
  m1_v = isl.UnionMap("[k] -> {V[i,j] -> [t0,t1,t2]: t0 = i and t1 = j and t2 = k}")
  m1 = m1_u.union(m1_v)
  print(m1)

source_raw:
  """for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }"""
  m1_u = isl.UnionMap("[k] -> {U[i,j] -> [t0,t1,t2]: t0 = i and t1 = j and t2 = k}")
  m1_v = isl.UnionMap("[k] -> {V[i,j] -> [t0,t1,t2]: t0 = i and t1 = j and t2 = k}")
  m1 = m1_u.union(m1_v)
  print(m1)


source:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("[k] -> {U[i,j] -> [t0,t1,t2]: t0 = i + 1 and t1 = j and t2 = k}")
  m1_v = isl.UnionMap("[k] -> {V[i,j] -> [t0,t1,t2]: t0 = i and t1 = j and t2 = k}")
  m1 = m1_u.union(m1_v)
  print(m1)

source_raw:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("[k] -> {U[i,j] -> [t0,t1,t2]: t0 = i + 1 and t1 = j and t2 = k}")
  m1_v = isl.UnionMap("[k] -> {V[i,j] -> [t0,t1,t2]: t0 = i and t1 = j and t2 = k}")
  m1 = m1_u.union(m1_v)
  print(m1)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j) {
  S:      C[j] = T[i][j]
      }

      for(int j = 0; j <=3; ++j) {
  T:      A[i] += C[j]
      }
  }
  """
  m2_s = isl.UnionMap("{S[i][j] -> [t0,t1]: t0 = i + 1 and t1 = j + 1}")
  m2_t = isl.UnionMap("{T[i][j] -> [t0,t1]: t0 = i + 1 and t1 = j + 1}")
  m2 = m2_s.union(m2_t)
  print(m2)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j) {
  S:      C[j] = T[i][j]
      }

      for(int j = 0; j <=3; ++j) {
  T:      A[i] += C[j]
      }
  }
  """
  m2_s = isl.UnionMap("{S[i][j] -> [t0,t1]: t0 = i + 1 and t1 = j + 1}")
  m2_t = isl.UnionMap("{T[i][j] -> [t0,t1]: t0 = i + 1 and t1 = j + 1}")
  m2 = m2_s.union(m2_t)
  print(m2)


source:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i + 1 and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)

source_raw:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i + 1 and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,t1,t2]: t0 = i and t1 = k and t2 = j}")

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,t1,t2]: t0 = i and t1 = k and t2 = j}")


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j) {
  S:      C[j] = T[i][j]
      }

      for(int j = 0; j <=3; ++j) {
  T:      A[i] += C[j]
      }
  }
  """
  m2_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m2_t = isl.UnionMap("{T[i][j] -> [t0,1,t1]: t0 = i and t1 = j}")
  m2 = m2_s.union(m2_t)
  print(m2)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j) {
  S:      C[j] = T[i][j]
      }

      for(int j = 0; j <=3; ++j) {
  T:      A[i] += C[j]
      }
  }
  """
  m2_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m2_t = isl.UnionMap("{T[i][j] -> [t0,1,t1]: t0 = i and t1 = j}")
  m2 = m2_s.union(m2_t)
  print(m2)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j and 0 <= i,j <= 3}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j and 0 <= i,j,k <= 3}")
  m3 = m3_s.union(m3_t)
  print(m3)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j and 0 <= i,j <= 3}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j and 0 <= i,j,k <= 3}")
  m3 = m3_s.union(m3_t)
  print(m3)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  s3 = isl.UnionMap("{S[i][j]: 0 <= i,j <= 3; T[i][k][j]: 0 <= i,k,j <= 3}")

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  s3 = isl.UnionMap("{S[i][j]: 0 <= i,j <= 3; T[i][k][j]: 0 <= i,k,j <= 3}")


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  s3 = isl.UnionMap("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  s3 = isl.UnionMap("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  s3 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s3)

  m3.intersect_domain(s3)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  s3 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s3)

  m3.intersect_domain(s3)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  s3 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s3)

  m3_constrained = m3.intersect_domain(s3)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  s3 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s3)

  m3_constrained = m3.intersect_domain(s3)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  s3 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s3)

  m3_constrained = m3.intersect_domain(s3)
  print(m3_constrained)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  s3 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s3)

  m3_constrained = m3.intersect_domain(s3)
  print(m3_constrained)


source:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i + 1 and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)

  # Constrain the schedules
  s1 = isl.UnionSet("{U[i,j]: 0 <= i,j <= 10; V[i,j]: 0 <= i,j <= 10}")
  print(s1)

  m1_constrained = m1.intersect_domain(s1)
  print(m1_constrained)

source_raw:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i + 1 and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)

  # Constrain the schedules
  s1 = isl.UnionSet("{U[i,j]: 0 <= i,j <= 10; V[i,j]: 0 <= i,j <= 10}")
  print(s1)

  m1_constrained = m1.intersect_domain(s1)
  print(m1_constrained)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j) {
  S:      C[j] = T[i][j]
      }

      for(int j = 0; j <=3; ++j) {
  T:      A[i] += C[j]
      }
  }
  """
  m2_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m2_t = isl.UnionMap("{T[i][j] -> [t0,1,t1]: t0 = i and t1 = j}")
  m2 = m2_s.union(m2_t)
  print(m2)

  # Constrain the schedules
  s2 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,j]: 0 <= i,j <= 3}")
  print(s2)

  m2_constrained = m2.intersect_domain(s2)
  print(m2_constrained)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j) {
  S:      C[j] = T[i][j]
      }

      for(int j = 0; j <=3; ++j) {
  T:      A[i] += C[j]
      }
  }
  """
  m2_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m2_t = isl.UnionMap("{T[i][j] -> [t0,1,t1]: t0 = i and t1 = j}")
  m2 = m2_s.union(m2_t)
  print(m2)

  # Constrain the schedules
  s2 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,j]: 0 <= i,j <= 3}")
  print(s2)

  m2_constrained = m2.intersect_domain(s2)
  print(m2_constrained)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  # Constrain the schedule
  s3 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s3)

  m3_constrained = m3.intersect_domain(s3)
  print(m3_constrained)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

  # Constrain the schedule
  s3 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s3)

  m3_constrained = m3.intersect_domain(s3)
  print(m3_constrained)


source:
  def print_code(domain, schedule):
      context = isl.Set("{ : }")
      build = isl.AstBuild.from_context(context)
      schedule = schedule.intersect_domain(domain)
      ast = build.node_from_schedule_map(schedule)
      printASTAsF(ast, isl.format.C)

source_raw:
  def print_code(domain, schedule):
      context = isl.Set("{ : }")
      build = isl.AstBuild.from_context(context)
      schedule = schedule.intersect_domain(domain)
      ast = build.node_from_schedule_map(schedule)
      printASTAsF(ast, isl.format.C)


source:
  # Print functions from sched-transform
  def printASTAsF(ast, f):
      p = isl.Printer.to_str(ast.get_ctx())
      p = p.set_output_format(f)
      p = p.print_ast_node(ast)
      print(p.get_str())

  def print_code(domain, schedule):
      context = isl.Set("{ : }")
      build = isl.AstBuild.from_context(context)
      schedule = schedule.intersect_domain(domain)
      ast = build.node_from_schedule_map(schedule)
      printASTAsF(ast, isl.format.C)

source_raw:
  # Print functions from sched-transform
  def printASTAsF(ast, f):
      p = isl.Printer.to_str(ast.get_ctx())
      p = p.set_output_format(f)
      p = p.print_ast_node(ast)
      print(p.get_str())

  def print_code(domain, schedule):
      context = isl.Set("{ : }")
      build = isl.AstBuild.from_context(context)
      schedule = schedule.intersect_domain(domain)
      ast = build.node_from_schedule_map(schedule)
      printASTAsF(ast, isl.format.C)


source:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i + 1 and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)

  # Constrain for the schedule
  s1 = isl.UnionSet("{U[i,j]: 0 <= i,j <= 10; V[i,j]: 0 <= i,j <= 10}")
  print_code(m1, s1)

source_raw:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i + 1 and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)

  # Constrain for the schedule
  s1 = isl.UnionSet("{U[i,j]: 0 <= i,j <= 10; V[i,j]: 0 <= i,j <= 10}")
  print_code(m1, s1)


source:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i + 1 and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)

  # Constrain for the schedule
  s1 = isl.UnionSet("{U[i,j]: 0 <= i,j <= 10; V[i,j]: 0 <= i,j <= 10}")
  print_code(s1, m1)

source_raw:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i + 1 and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)

  # Constrain for the schedule
  s1 = isl.UnionSet("{U[i,j]: 0 <= i,j <= 10; V[i,j]: 0 <= i,j <= 10}")
  print_code(s1, m1)


source:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)

  # Constrain for the schedule
  s1 = isl.UnionSet("{U[i,j]: 0 <= i,j <= 10; V[i,j]: 0 <= i,j <= 10}")
  print_code(s1, m1)

source_raw:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)

  # Constrain for the schedule
  s1 = isl.UnionSet("{U[i,j]: 0 <= i,j <= 10; V[i,j]: 0 <= i,j <= 10}")
  print_code(s1, m1)


source:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)

source_raw:
  """
  for (i = 0; i < 10; ++i)
      for (j = 0; j < 10; j++) {
  U:      A[i][j] = 0.0;
  V:      B[j][i] = 1.0;
      }
  """
  m1_u = isl.UnionMap("{U[i,j] -> [t0,t1,0]: t0 = i and t1 = j}")
  m1_v = isl.UnionMap("{V[i,j] -> [t0,t1,1]: t0 = i and t1 = j}")
  m1 = m1_u.union(m1_v)
  print(m1)


source:
  # Constrain for the schedule
  s1 = isl.UnionSet("{U[i,j]: 0 <= i,j <= 10; V[i,j]: 0 <= i,j <= 10}")
  print(s1)

source_raw:
  # Constrain for the schedule
  s1 = isl.UnionSet("{U[i,j]: 0 <= i,j <= 10; V[i,j]: 0 <= i,j <= 10}")
  print(s1)


source:
  # Constrain for the schedule
  s2 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,j]: 0 <= i,j <= 3}")
  print(s2)

source_raw:
  # Constrain for the schedule
  s2 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,j]: 0 <= i,j <= 3}")
  print(s2)


source:
  # Constrain for the schedule
  s3 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s3)

source_raw:
  # Constrain for the schedule
  s3 = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3; T[i,k,j]: 0 <= i,k,j <= 3}")
  print(s3)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1,0]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1,0]: t0 = i and t1 = j}")
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1,0]: t0 = i and t1 = j}") # <-- The last 0 is important! They need the same dimension
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];

      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """
  m3_s = isl.UnionMap("{S[i][j] -> [t0,0,t1,0]: t0 = i and t1 = j}") # <-- The last 0 is important! They need the same dimension
  m3_t = isl.UnionMap("{T[i][k][j] -> [t0,1,t1,t2]: t0 = i and t1 = k and t2 = j}")
  m3 = m3_s.union(m3_t)
  print(m3)


source:
  A_S_B = isl.Map("{S[i,j] -> B[a]: a = i}")
  A_S_A = isl.Map("{S[i,j] -> A[a,b]: a = i and b = j}")
  print (A_S_A)

source_raw:
  A_S_B = isl.Map("{S[i,j] -> B[a]: a = i}")
  A_S_A = isl.Map("{S[i,j] -> A[a,b]: a = i and b = j}")
  print (A_S_A)


source:
  m1_S_C = isl.UnionMap("{S[i,j] -> C[a, b]: a = i and b = j}")
  m1_T_A = isl.UnionMap("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  m1_T_B = isl.UnionMap("{T[i,k,j] -> B[a,b]: a = k and b = j}")
  m1_T_C = isl.UnionMap("{T[i,k,j] -> C[a,b]: a = i and b = j}")

source_raw:
  m1_S_C = isl.UnionMap("{S[i,j] -> C[a, b]: a = i and b = j}")
  m1_T_A = isl.UnionMap("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  m1_T_B = isl.UnionMap("{T[i,k,j] -> B[a,b]: a = k and b = j}")
  m1_T_C = isl.UnionMap("{T[i,k,j] -> C[a,b]: a = i and b = j}")


source:
  m1_S_C = isl.UnionMap("{S[i,j] -> C[a, b]: a = i and b = j}")
  m1_T_A = isl.UnionMap("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  m1_T_B = isl.UnionMap("{T[i,k,j] -> B[a,b]: a = k and b = j}")
  m1_T_C = isl.UnionMap("{T[i,k,j] -> C[a,b]: a = i and b = j}")
  m1 = m1_S_C.union(m1_T_A).union(m1_T_B).union(m1_T_C)

  print(m1)

source_raw:
  m1_S_C = isl.UnionMap("{S[i,j] -> C[a, b]: a = i and b = j}")
  m1_T_A = isl.UnionMap("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  m1_T_B = isl.UnionMap("{T[i,k,j] -> B[a,b]: a = k and b = j}")
  m1_T_C = isl.UnionMap("{T[i,k,j] -> C[a,b]: a = i and b = j}")
  m1 = m1_S_C.union(m1_T_A).union(m1_T_B).union(m1_T_C)

  print(m1)


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];
      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """

  m1_S_C = isl.UnionMap("{S[i,j] -> C[a, b]: a = i and b = j}")
  m1_T_A = isl.UnionMap("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  m1_T_B = isl.UnionMap("{T[i,k,j] -> B[a,b]: a = k and b = j}")
  m1_T_C = isl.UnionMap("{T[i,k,j] -> C[a,b]: a = i and b = j}")
  m1 = m1_S_C.union(m1_T_A).union(m1_T_B).union(m1_T_C)

  print(m1)

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];
      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """

  m1_S_C = isl.UnionMap("{S[i,j] -> C[a, b]: a = i and b = j}")
  m1_T_A = isl.UnionMap("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  m1_T_B = isl.UnionMap("{T[i,k,j] -> B[a,b]: a = k and b = j}")
  m1_T_C = isl.UnionMap("{T[i,k,j] -> C[a,b]: a = i and b = j}")
  m1 = m1_S_C.union(m1_T_A).union(m1_T_B).union(m1_T_C)

  print(m1)


source:
  s1_S = isl.UnionSet("{S[i,j]: 0 <= i,k <= 3}")
  s1_A = isl.UnionSet("{A[a,b]: 0 <= a,b <= 3}")
  s1_B = isl.UnionSet("{B[a,b]: 0 <= a,b <= 3}")
  s1_C = isl.UnionSet("{C[a,b]: 0 <= a,b <= 3}")
  s1_T = isl.UnionSet("{T[i,j]: 0 <= i,k,j <= 3")
  s1 = s1_S.union(s1_A).union(s1_B).union(s1_C).union(s1_T)

source_raw:
  s1_S = isl.UnionSet("{S[i,j]: 0 <= i,k <= 3}")
  s1_A = isl.UnionSet("{A[a,b]: 0 <= a,b <= 3}")
  s1_B = isl.UnionSet("{B[a,b]: 0 <= a,b <= 3}")
  s1_C = isl.UnionSet("{C[a,b]: 0 <= a,b <= 3}")
  s1_T = isl.UnionSet("{T[i,j]: 0 <= i,k,j <= 3")
  s1 = s1_S.union(s1_A).union(s1_B).union(s1_C).union(s1_T)


source:
  s1_S = isl.UnionSet("{S[i,j]: 0 <= i,k <= 3}")
  s1_A = isl.UnionSet("{A[a,b]: 0 <= a,b <= 3}")
  s1_B = isl.UnionSet("{B[a,b]: 0 <= a,b <= 3}")
  s1_C = isl.UnionSet("{C[a,b]: 0 <= a,b <= 3}")
  s1_T = isl.UnionSet("{T[i,k,j]: 0 <= i,k,j <= 3")
  s1 = s1_S.union(s1_A).union(s1_B).union(s1_C).union(s1_T)

source_raw:
  s1_S = isl.UnionSet("{S[i,j]: 0 <= i,k <= 3}")
  s1_A = isl.UnionSet("{A[a,b]: 0 <= a,b <= 3}")
  s1_B = isl.UnionSet("{B[a,b]: 0 <= a,b <= 3}")
  s1_C = isl.UnionSet("{C[a,b]: 0 <= a,b <= 3}")
  s1_T = isl.UnionSet("{T[i,k,j]: 0 <= i,k,j <= 3")
  s1 = s1_S.union(s1_A).union(s1_B).union(s1_C).union(s1_T)


source:
  s1_S = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3}")
  s1_A = isl.UnionSet("{A[a,b]: 0 <= a,b <= 3}")
  s1_B = isl.UnionSet("{B[a,b]: 0 <= a,b <= 3}")
  s1_C = isl.UnionSet("{C[a,b]: 0 <= a,b <= 3}")
  s1_T = isl.UnionSet("{T[i,k,j]: 0 <= i,k,j <= 3")
  s1 = s1_S.union(s1_A).union(s1_B).union(s1_C).union(s1_T)

source_raw:
  s1_S = isl.UnionSet("{S[i,j]: 0 <= i,j <= 3}")
  s1_A = isl.UnionSet("{A[a,b]: 0 <= a,b <= 3}")
  s1_B = isl.UnionSet("{B[a,b]: 0 <= a,b <= 3}")
  s1_C = isl.UnionSet("{C[a,b]: 0 <= a,b <= 3}")
  s1_T = isl.UnionSet("{T[i,k,j]: 0 <= i,k,j <= 3")
  s1 = s1_S.union(s1_A).union(s1_B).union(s1_C).union(s1_T)


source:
  m1_read = m1_S_C.union(m1_T_A).union(m1_T_B).union(m1_T_C)
  print(m1_read)
  m1_write = m1_S_C.union(m1_T_C)
  print(m1_write)

source_raw:
  m1_read = m1_S_C.union(m1_T_A).union(m1_T_B).union(m1_T_C)
  print(m1_read)
  m1_write = m1_S_C.union(m1_T_C)
  print(m1_write)


source:
  m1_read = m1_S_C.union(m1_T_A).union(m1_T_B).union(m1_T_C)
  m1_read
  m1_write = m1_S_C.union(m1_T_C)
  m1_write

source_raw:
  m1_read = m1_S_C.union(m1_T_A).union(m1_T_B).union(m1_T_C)
  m1_read
  m1_write = m1_S_C.union(m1_T_C)
  m1_write


source:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];
      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """

  m1_S_C = isl.UnionMap("{S[i,j] -> C[a, b]: a = i and b = j}")
  m1_T_A = isl.UnionMap("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  m1_T_B = isl.UnionMap("{T[i,k,j] -> B[a,b]: a = k and b = j}")
  m1_T_C = isl.UnionMap("{T[i,k,j] -> C[a,b]: a = i and b = j}")

source_raw:
  """
  for(int i = 0; i <= 3; ++i) {
      for(int j = 0; j <= 3; ++j)
  S:      C[i][j] = beta * C[i][j];
      for(int k = 0; k <= 3; ++k)
          for(int j = 0; j <= 3; ++j)
  T:          C[i][j] = C[i][j] + alpha * A[i][k] * B[k][j];
  }
  """

  m1_S_C = isl.UnionMap("{S[i,j] -> C[a, b]: a = i and b = j}")
  m1_T_A = isl.UnionMap("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  m1_T_B = isl.UnionMap("{T[i,k,j] -> B[a,b]: a = k and b = j}")
  m1_T_C = isl.UnionMap("{T[i,k,j] -> C[a,b]: a = i and b = j}")


source:
  d_a = isl.UnionSet("{A[a]: 0 <= a < 100}")
  d_s = isl.UnionSet("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i +5}")

  s2.intersect_domain(d_a).intersect_domain(d_s)

source_raw:
  d_a = isl.UnionSet("{A[a]: 0 <= a < 100}")
  d_s = isl.UnionSet("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i +5}")

  s2.intersect_domain(d_a).intersect_domain(d_s)


source:
  d_a = isl.UnionSet("{A[a]: 0 <= a < 100}")
  d_s = isl.UnionSet("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  s2.intersect_domain(d_a).intersect_domain(d_s)

source_raw:
  d_a = isl.UnionSet("{A[a]: 0 <= a < 100}")
  d_s = isl.UnionSet("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  s2.intersect_domain(d_a).intersect_domain(d_s)


source:
  d_a = isl.UnionSet("{A[a]: 0 <= a < 100}")
  d_s = isl.UnionSet("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i}")

  s2.intersect_domain(d_a).intersect_domain(d_s)

source_raw:
  d_a = isl.UnionSet("{A[a]: 0 <= a < 100}")
  d_s = isl.UnionSet("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i}")

  s2.intersect_domain(d_a).intersect_domain(d_s)


source:
  d_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  s2.intersect_domain(d_a).intersect_domain(d_s)

source_raw:
  d_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  s2.intersect_domain(d_a).intersect_domain(d_s)


source:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  s2.intersect_domain(d_s).intersect_range(c_a)

source_raw:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  s2.intersect_domain(d_s).intersect_range(c_a)


source:
  ATA = isl.Map("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  DT = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  CA = isl.Set("{A[a,b]: 0 <= a,b <= 3}")
  ATA = ATA.intersect_domain(DT).intersect_range(CA)

source_raw:
  ATA = isl.Map("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  DT = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  CA = isl.Set("{A[a,b]: 0 <= a,b <= 3}")
  ATA = ATA.intersect_domain(DT).intersect_range(CA)


source:
  ATA = isl.Map("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  DT = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  CA = isl.Set("{A[a,b]: 0 <= a,b <= 3}")
  ATA.intersect_domain(DT).intersect_range(CA)

source_raw:
  ATA = isl.Map("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  DT = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  CA = isl.Set("{A[a,b]: 0 <= a,b <= 3}")
  ATA.intersect_domain(DT).intersect_range(CA)


source:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  print(s2.intersect_domain(d_s).intersect_range(c_a))

source_raw:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  print(s2.intersect_domain(d_s).intersect_range(c_a))


source:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  correct = s2.intersect_domain(d_s).intersect_range(c_a)
  print(correct)
  incorrect = s2.intersect_domain(d_s)
  print(incorrect)

source_raw:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  correct = s2.intersect_domain(d_s).intersect_range(c_a)
  print(correct)
  incorrect = s2.intersect_domain(d_s)
  print(incorrect)


source:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  correct = s2.intersect_domain(d_s).intersect_range(c_a)
  print(correct)
  incorrect = s2.intersect_domain(d_s)
  print(incorrect)
  illegal = incorrect.subtract(c_a)
  print(incorrect)

source_raw:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  correct = s2.intersect_domain(d_s).intersect_range(c_a)
  print(correct)
  incorrect = s2.intersect_domain(d_s)
  print(incorrect)
  illegal = incorrect.subtract(c_a)
  print(incorrect)


source:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  correct = s2.intersect_domain(d_s).intersect_range(c_a)
  print(correct)
  incorrect = s2.intersect_domain(d_s)
  print(incorrect)
  illegal = incorrect.subtract(correct)
  print(incorrect)

source_raw:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  correct = s2.intersect_domain(d_s).intersect_range(c_a)
  print(correct)
  incorrect = s2.intersect_domain(d_s)
  print(incorrect)
  illegal = incorrect.subtract(correct)
  print(incorrect)


source:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  correct = s2.intersect_domain(d_s).intersect_range(c_a)
  print(correct)
  incorrect = s2.intersect_domain(d_s)
  print(incorrect)
  illegal = incorrect.subtract(correct)
  print(illegal)

source_raw:
  c_a = isl.Set("{A[a]: 0 <= a < 100}")
  d_s = isl.Set("{S[i]: 0 <= i < 100}")
  s2 = isl.UnionMap("{S[i] -> A[a]: a = i + 5}")

  correct = s2.intersect_domain(d_s).intersect_range(c_a)
  print(correct)
  incorrect = s2.intersect_domain(d_s)
  print(incorrect)
  illegal = incorrect.subtract(correct)
  print(illegal)


source:
  a_s_a = isl.UnionMap("{S[i,j] -> A[a,b]: a = i and b = j}")
  a_s_b = isl.UnionMap("{S[i,j] -> B[a]: a = i}")
  d_s = isl.Set("S[i,j]: 0 <= i <= n and 0 <= j <= 3")

  print(a_s_a.intersect_domain(d_s))

source_raw:
  a_s_a = isl.UnionMap("{S[i,j] -> A[a,b]: a = i and b = j}")
  a_s_b = isl.UnionMap("{S[i,j] -> B[a]: a = i}")
  d_s = isl.Set("S[i,j]: 0 <= i <= n and 0 <= j <= 3")

  print(a_s_a.intersect_domain(d_s))


source:
  a_s_a = isl.UnionMap("{S[i,j] -> A[a,b]: a = i and b = j}")
  a_s_b = isl.UnionMap("{S[i,j] -> B[a]: a = i}")
  d_s = isl.Set("{S[i,j]: 0 <= i <= n and 0 <= j <= 3}")

  print(a_s_a.intersect_domain(d_s))

source_raw:
  a_s_a = isl.UnionMap("{S[i,j] -> A[a,b]: a = i and b = j}")
  a_s_b = isl.UnionMap("{S[i,j] -> B[a]: a = i}")
  d_s = isl.Set("{S[i,j]: 0 <= i <= n and 0 <= j <= 3}")

  print(a_s_a.intersect_domain(d_s))


source:
  a_s_a = isl.UnionMap("{S[i,j] -> A[a,b]: a = i and b = j}")
  a_s_b = isl.UnionMap("{S[i,j] -> B[a]: a = i}")
  d_s = isl.Set("[n] -> {S[i,j]: 0 <= i <= n and 0 <= j <= 3}")

  print(a_s_a.intersect_domain(d_s))

source_raw:
  a_s_a = isl.UnionMap("{S[i,j] -> A[a,b]: a = i and b = j}")
  a_s_b = isl.UnionMap("{S[i,j] -> B[a]: a = i}")
  d_s = isl.Set("[n] -> {S[i,j]: 0 <= i <= n and 0 <= j <= 3}")

  print(a_s_a.intersect_domain(d_s))


source:
  a_s_a = isl.UnionMap("{S[i,j] -> A[a,b]: a = i and b = j}")
  a_s_b = isl.UnionMap("{S[i,j] -> B[a]: a = i}")
  d_s = isl.Set("[n] -> {S[i,j]: 0 <= i <= n and 0 <= j <= 3}")

  print(a_s_a.intersect_domain(d_s).is_injective())

source_raw:
  a_s_a = isl.UnionMap("{S[i,j] -> A[a,b]: a = i and b = j}")
  a_s_b = isl.UnionMap("{S[i,j] -> B[a]: a = i}")
  d_s = isl.Set("[n] -> {S[i,j]: 0 <= i <= n and 0 <= j <= 3}")

  print(a_s_a.intersect_domain(d_s).is_injective())


source:
  a_s_a = isl.UnionMap("{S[i,j] -> A[a,b]: a = i and b = j}")
  a_s_b = isl.UnionMap("{S[i,j] -> B[a]: a = i}")
  d_s = isl.Set("[n] -> {S[i,j]: 0 <= i <= n and 0 <= j <= 3}")

  print(a_s_a.intersect_domain(d_s).is_injective())
  print(a_s_b.intersect_domain(d_s).is_injective())

source_raw:
  a_s_a = isl.UnionMap("{S[i,j] -> A[a,b]: a = i and b = j}")
  a_s_b = isl.UnionMap("{S[i,j] -> B[a]: a = i}")
  d_s = isl.Set("[n] -> {S[i,j]: 0 <= i <= n and 0 <= j <= 3}")

  print(a_s_a.intersect_domain(d_s).is_injective())
  print(a_s_b.intersect_domain(d_s).is_injective())


source:
  def printASTAsF(ast, f):
      p = isl.Printer.to_str(ast.get_ctx())
      p = p.set_output_format(f)
      p = p.print_ast_node(ast)
      print(p.get_str())

  def print_code(domain, schedule):
      context = isl.Set("{ : }")
      build = isl.AstBuild.from_context(context)
      schedule = schedule.intersect_domain(domain)
      ast = build.node_from_schedule_map(schedule)
      printASTAsF(ast, isl.format.C)

source_raw:
  def printASTAsF(ast, f):
      p = isl.Printer.to_str(ast.get_ctx())
      p = p.set_output_format(f)
      p = p.print_ast_node(ast)
      print(p.get_str())

  def print_code(domain, schedule):
      context = isl.Set("{ : }")
      build = isl.AstBuild.from_context(context)
      schedule = schedule.intersect_domain(domain)
      ast = build.node_from_schedule_map(schedule)
      printASTAsF(ast, isl.format.C)


source:
  #domains
  D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  D_T = isl.Set("{T[i,j]: 5 <= i,j <= 8}")
  domain = isl.UnionSet("{}")
  domain = domain.union(D_S).union(D_T)

  schedule_D = isl.UnionMap("{S[i,j] -> [t0,t1,t2]: t0 = 0 and t1 = i and t2 = j}")
  schedule_T = isl.UnionMap("{T[i,j] -> [t0,t1,t2]: t0 = 1 and t1 = i and t2 = j}")

  schedule = schedule_D.union(schedule_T)

  #access relations
  A_S_C = isl.Map("{S[i,j] -> C[a,b]: a = i and b = j}")
  A_T_C = isl.Map("{T[i,j] -> C[a,b]: a = i-5 and b = j-5}")
  A_T_A = isl.Map("{T[i,j] -> A[a,b]: a = i and b = j}")

source_raw:
  #domains
  D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  D_T = isl.Set("{T[i,j]: 5 <= i,j <= 8}")
  domain = isl.UnionSet("{}")
  domain = domain.union(D_S).union(D_T)

  schedule_D = isl.UnionMap("{S[i,j] -> [t0,t1,t2]: t0 = 0 and t1 = i and t2 = j}")
  schedule_T = isl.UnionMap("{T[i,j] -> [t0,t1,t2]: t0 = 1 and t1 = i and t2 = j}")

  schedule = schedule_D.union(schedule_T)

  #access relations
  A_S_C = isl.Map("{S[i,j] -> C[a,b]: a = i and b = j}")
  A_T_C = isl.Map("{T[i,j] -> C[a,b]: a = i-5 and b = j-5}")
  A_T_A = isl.Map("{T[i,j] -> A[a,b]: a = i and b = j}")


source:
  #iteration domains - matmul example
  D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  D_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= k <= 3 and 0 <= j <= 3}")

source_raw:
  #iteration domains - matmul example
  D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  D_T = isl.Set("{T[i,k,j]: 0 <= i <= 3 and 0 <= k <= 3 and 0 <= j <= 3}")


source:
  A_S_C = isl.Map("{S[i,j] -> C[a,b]: a = i and b = j}")
  A_T_C = isl.Map("{T[i,k,j] -> C[a,b]: a = i and b = j}")
  A_T_A = isl.Map("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  A_T_B = isl.Map("{T[i,k,j] -> B[a,b]: a = k and b = j}")

source_raw:
  A_S_C = isl.Map("{S[i,j] -> C[a,b]: a = i and b = j}")
  A_T_C = isl.Map("{T[i,k,j] -> C[a,b]: a = i and b = j}")
  A_T_A = isl.Map("{T[i,k,j] -> A[a,b]: a = i and b = k}")
  A_T_B = isl.Map("{T[i,k,j] -> B[a,b]: a = k and b = j}")


source:
  A_S_C = A_S_C.intersect_domain(D_S)
  A_T_C = A_T_C.intersect_domain(D_T)
  A_T_A = A_T_A.intersect_domain(D_T)
  A_T_B = A_T_B.intersect_domain(D_T)

source_raw:
  A_S_C = A_S_C.intersect_domain(D_S)
  A_T_C = A_T_C.intersect_domain(D_T)
  A_T_A = A_T_A.intersect_domain(D_T)
  A_T_B = A_T_B.intersect_domain(D_T)


source:
  D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  D_T = isl.Set("{T[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  A_S_C = isl.Map("{S[i,j] -> C[a]: a = j}")
  A_S_T = isl.Map("{S[i,j] -> B[a, b]: a = i and b = j}")
  A_T_A = isl.Map("{T[i,j] -> A[a]: a = i}")
  A_T_C = isl.Map("{T[i,j] -> C[a]: a = j}")

source_raw:
  D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  D_T = isl.Set("{T[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  A_S_C = isl.Map("{S[i,j] -> C[a]: a = j}")
  A_S_T = isl.Map("{S[i,j] -> B[a, b]: a = i and b = j}")
  A_T_A = isl.Map("{T[i,j] -> A[a]: a = i}")
  A_T_C = isl.Map("{T[i,j] -> C[a]: a = j}")


source:
  D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  D_T = isl.Set("{T[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")

source_raw:
  D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  D_T = isl.Set("{T[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")


source:
  A_S_C = isl.Map("{S[i,j] -> C[a]: a = j}")
  A_S_T = isl.Map("{S[i,j] -> B[a, b]: a = i and b = j}")
  A_T_A = isl.Map("{T[i,j] -> A[a]: a = i}")
  A_T_C = isl.Map("{T[i,j] -> C[a]: a = j}")

source_raw:
  A_S_C = isl.Map("{S[i,j] -> C[a]: a = j}")
  A_S_T = isl.Map("{S[i,j] -> B[a, b]: a = i and b = j}")
  A_T_A = isl.Map("{T[i,j] -> A[a]: a = i}")
  A_T_C = isl.Map("{T[i,j] -> C[a]: a = j}")


source:
  A_S_C = A_S_C.intersect_domain(D_S)
  A_S_T = A_S_T.intersect_domain(D_S)
  A_T_A = A_T_A.intersect_domain(D_T)
  A_T_C = A_T_C.intersect_domain(D_T)

source_raw:
  A_S_C = A_S_C.intersect_domain(D_S)
  A_S_T = A_S_T.intersect_domain(D_S)
  A_T_A = A_T_A.intersect_domain(D_T)
  A_T_C = A_T_C.intersect_domain(D_T)


source:
  read_rels = isl.UnionMap("{}").union(A_S_T).union(A_T_C)
  write_reals = isl.UnionMap("{}").union(A_S_C).union(A_T_A)

source_raw:
  read_rels = isl.UnionMap("{}").union(A_S_T).union(A_T_C)
  write_reals = isl.UnionMap("{}").union(A_S_C).union(A_T_A)


source:
  read_rels = isl.UnionMap("{}").union(A_S_T).union(A_T_C)
  write_rels = isl.UnionMap("{}").union(A_S_C).union(A_T_A)

source_raw:
  read_rels = isl.UnionMap("{}").union(A_S_T).union(A_T_C)
  write_rels = isl.UnionMap("{}").union(A_S_C).union(A_T_A)


source:
  deps_raw = read_rels.apply_range(write_rels.reverse())
  print(deps_raw)
  deps_war = write_rels.apply_range(read_rels.reverse())
  print(deps_war)
  deps_rar = A_T_C.apply_range(A_S_T.reverse())

source_raw:
  deps_raw = read_rels.apply_range(write_rels.reverse())
  print(deps_raw)
  deps_war = write_rels.apply_range(read_rels.reverse())
  print(deps_war)
  deps_rar = A_T_C.apply_range(A_S_T.reverse())


source:
  deps_raw = read_rels.apply_range(write_rels.reverse())
  print(deps_raw)
  deps_war = write_rels.apply_range(read_rels.reverse())
  print(deps_war)
  deps_rar = isl.UnionMap("{}").union(A_T_C).apply_range(A_S_T.reverse())

source_raw:
  deps_raw = read_rels.apply_range(write_rels.reverse())
  print(deps_raw)
  deps_war = write_rels.apply_range(read_rels.reverse())
  print(deps_war)
  deps_rar = isl.UnionMap("{}").union(A_T_C).apply_range(A_S_T.reverse())


source:
  deps_raw = read_rels.apply_range(write_rels.reverse())
  print(deps_raw)
  deps_war = write_rels.apply_range(read_rels.reverse())
  print(deps_war)
  deps_rar = isl.UnionMap("{}").union(A_T_C).apply_range(A_S_T.reverse())
  print(deps_rar)

source_raw:
  deps_raw = read_rels.apply_range(write_rels.reverse())
  print(deps_raw)
  deps_war = write_rels.apply_range(read_rels.reverse())
  print(deps_war)
  deps_rar = isl.UnionMap("{}").union(A_T_C).apply_range(A_S_T.reverse())
  print(deps_rar)


source:
  deps_raw = read_rels.apply_range(write_rels.reverse())
  print(deps_raw)
  deps_war = write_rels.apply_range(read_rels.reverse())
  print(deps_war)
  deps_rar = isl.UnionMap("{}").union(A_T_C).apply_range(A_S_T.reverse())
  print(deps_rar)
  deps_waw = isl.UnionMap("{}").union(A_T_A).apply_range(A_S_C.reverse())
  print(deps_waw)

source_raw:
  deps_raw = read_rels.apply_range(write_rels.reverse())
  print(deps_raw)
  deps_war = write_rels.apply_range(read_rels.reverse())
  print(deps_war)
  deps_rar = isl.UnionMap("{}").union(A_T_C).apply_range(A_S_T.reverse())
  print(deps_rar)
  deps_waw = isl.UnionMap("{}").union(A_T_A).apply_range(A_S_C.reverse())
  print(deps_waw)


source:
  deps_WAR = read_rels.apply_range(write_rels.reverse())
  print(deps_WAR)
  deps_RAW = write_rels.apply_range(read_rels.reverse())
  print(deps_RAW)
  deps_RAR = isl.UnionMap("{}").union(A_T_C).apply_range(A_S_T.reverse())
  print(deps_RAR)
  deps_WAW = isl.UnionMap("{}").union(A_T_A).apply_range(A_S_C.reverse())
  print(deps_WAW)

source_raw:
  deps_WAR = read_rels.apply_range(write_rels.reverse())
  print(deps_WAR)
  deps_RAW = write_rels.apply_range(read_rels.reverse())
  print(deps_RAW)
  deps_RAR = isl.UnionMap("{}").union(A_T_C).apply_range(A_S_T.reverse())
  print(deps_RAR)
  deps_WAW = isl.UnionMap("{}").union(A_T_A).apply_range(A_S_C.reverse())
  print(deps_WAW)


source:
  D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  D_T = isl.Set("{T[i,j]: 5 <= i <= 8 and 5 <= j <= 8}")

source_raw:
  D_S = isl.Set("{S[i,j]: 0 <= i <= 3 and 0 <= j <= 3}")
  D_T = isl.Set("{T[i,j]: 5 <= i <= 8 and 5 <= j <= 8}")


source:
  A_S_C = isl.Map("{S[i,j] -> C[a,b]: a = i and b = j}").intersect_domain(D_S)  #write
  A_T_A = isl.Map("{T[i,j] -> A[a,b]: a = i and b = j}").intersect_domain(D_T)  #write
  A_T_A = isl.Map("{T[i,j] -> C[a,b]: a = i-5 and b = j-5}").intersect_domain(D_T)  #read

source_raw:
  A_S_C = isl.Map("{S[i,j] -> C[a,b]: a = i and b = j}").intersect_domain(D_S)  #write
  A_T_A = isl.Map("{T[i,j] -> A[a,b]: a = i and b = j}").intersect_domain(D_T)  #write
  A_T_A = isl.Map("{T[i,j] -> C[a,b]: a = i-5 and b = j-5}").intersect_domain(D_T)  #read


source:
  A_S_C = isl.Map("{S[i,j] -> C[a,b]: a = i and b = j}").intersect_domain(D_S)  #write
  A_T_A = isl.Map("{T[i,j] -> A[a,b]: a = i and b = j}").intersect_domain(D_T)  #write
  A_T_C = isl.Map("{T[i,j] -> C[a,b]: a = i-5 and b = j-5}").intersect_domain(D_T)  #read

source_raw:
  A_S_C = isl.Map("{S[i,j] -> C[a,b]: a = i and b = j}").intersect_domain(D_S)  #write
  A_T_A = isl.Map("{T[i,j] -> A[a,b]: a = i and b = j}").intersect_domain(D_T)  #write
  A_T_C = isl.Map("{T[i,j] -> C[a,b]: a = i-5 and b = j-5}").intersect_domain(D_T)  #read


source:
  read_rels = isl.UnionMap("{}").union(A_S_T).union(A_T_C).union(A_T_A)
  write_rels = isl.UnionMap("{}").union(A_S_C).union(A_T_A)

source_raw:
  read_rels = isl.UnionMap("{}").union(A_S_T).union(A_T_C).union(A_T_A)
  write_rels = isl.UnionMap("{}").union(A_S_C).union(A_T_A)


source:
  #Task: 5.1 (a)
  domain = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < N}")
  schedule = isl.UnionMap("{S[i,j] -> [j, i]")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (a)
  domain = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < N}")
  schedule = isl.UnionMap("{S[i,j] -> [j, i]")
  print_code(domain, schedule)


source:
  #Task: 5.1 (a)
  domain = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < N}")
  schedule = isl.UnionMap("{S[i,j] -> S[j,i]")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (a)
  domain = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < N}")
  schedule = isl.UnionMap("{S[i,j] -> S[j,i]")
  print_code(domain, schedule)


source:
  #Task: 5.1 (a)
  domain = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < N}")
  schedule = isl.UnionMap("{S[i,j] -> [j,i]")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (a)
  domain = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < N}")
  schedule = isl.UnionMap("{S[i,j] -> [j,i]")
  print_code(domain, schedule)


source:
  #Task: 5.1 (a)
  domain = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < N}")
  schedule = isl.UnionMap("{S[i,j] -> [j,i]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (a)
  domain = isl.Set("[N] -> {S[i,j]: 0 <= i < N and 0 <= j < N}")
  schedule = isl.UnionMap("{S[i,j] -> [j,i]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (b)
  domain_S = isl.Set("[N] -> {S[i]:  0 <= i < N}")
  domain_T = isl.Set("[N] -> {T[j]:  0 <= j < N}")
  domain = isl.UnionSet("{}").union(domain_S).union(domain_T)
  schedule_S = isl.UnionMap("{S[i] -> [i]}")
  schedule_T = isl.UnionMap("{T[j] -> [j]}")
  schedule = isl.UnionMap("{}").union(schedule_S).union(schedule_T)
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (b)
  domain_S = isl.Set("[N] -> {S[i]:  0 <= i < N}")
  domain_T = isl.Set("[N] -> {T[j]:  0 <= j < N}")
  domain = isl.UnionSet("{}").union(domain_S).union(domain_T)
  schedule_S = isl.UnionMap("{S[i] -> [i]}")
  schedule_T = isl.UnionMap("{T[j] -> [j]}")
  schedule = isl.UnionMap("{}").union(schedule_S).union(schedule_T)
  print_code(domain, schedule)


source:
  #Task: 5.1 (c)
  domain_S = isl.Set("[N] -> {S[i]:  0 <= i < N}")
  domain_T = isl.Set("[N] -> {T[i]:  0 <= i < N}")
  domain = isl.UnionSet("{}").union(domain_S).union(domain_T)
  schedule_S = isl.UnionMap("{S[i] -> [0, i]}")
  schedule_T = isl.UnionMap("{T[i] -> [1, i]}")
  schedule = isl.UnionMap("{}").union(schedule_S).union(schedule_T)
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (c)
  domain_S = isl.Set("[N] -> {S[i]:  0 <= i < N}")
  domain_T = isl.Set("[N] -> {T[i]:  0 <= i < N}")
  domain = isl.UnionSet("{}").union(domain_S).union(domain_T)
  schedule_S = isl.UnionMap("{S[i] -> [0, i]}")
  schedule_T = isl.UnionMap("{T[i] -> [1, i]}")
  schedule = isl.UnionMap("{}").union(schedule_S).union(schedule_T)
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[i,j] -> [i+j]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[i,j] -> [i+j]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[i,j] -> [a = i+j]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[i,j] -> [a = i+j]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[a] -> [a = i+j]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[a] -> [a = i+j]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[i,j] -> S[i+j]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[i,j] -> S[i+j]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[i,j] -> [a=i+j]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[i,j] -> [a=i+j]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (e)
  domain = isl.Set("{S[i,j,k,l]: 0 <= i,j < 16 and 0 <= k,l < 4}")
  schedule = isl.UnionMap("{S[i,j,k,l] -> [i+k, j+l]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (e)
  domain = isl.Set("{S[i,j,k,l]: 0 <= i,j < 16 and 0 <= k,l < 4}")
  schedule = isl.UnionMap("{S[i,j,k,l] -> [i+k, j+l]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[i,j] -> T[a=i+j]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 16}")
  schedule = isl.UnionMap("{S[i,j] -> T[a=i+j]}")
  print_code(domain, schedule)


source:
  def printASTAsF(ast, f):
      p = isl.Printer.to_str(ast.get_ctx())
      p = p.set_output_format(f)
      p = p.print_ast_node(ast)
      print(p.get_str())

  def print_code(domain, schedule):
      context = isl.Set("{ : }")
      build = isl.AstBuild.from_context(context)
      schedule = schedule.intersect_domain(domain)
      ast = build.node_from_schedule_map(schedule)
      printASTAsF(ast, isl.format.C)

  def print_before_after(domain, schedule_original, schedule_new):
      context = isl.Set("{ : }")
      build = isl.AstBuild.from_context(context)
      schedule_original = schedule_original.intersect_domain(domain)
      schedule_new = schedule_new.intersect_domain(domain)
      print("Before Transform:\n")
      ast = build.node_from_schedule_map(schedule_original)
      printASTAsF(ast, isl.format.C)
      print("After Transform:\n")
      ast = build.node_from_schedule_map(schedule_new)
      printASTAsF(ast, isl.format.C)

source_raw:
  def printASTAsF(ast, f):
      p = isl.Printer.to_str(ast.get_ctx())
      p = p.set_output_format(f)
      p = p.print_ast_node(ast)
      print(p.get_str())

  def print_code(domain, schedule):
      context = isl.Set("{ : }")
      build = isl.AstBuild.from_context(context)
      schedule = schedule.intersect_domain(domain)
      ast = build.node_from_schedule_map(schedule)
      printASTAsF(ast, isl.format.C)

  def print_before_after(domain, schedule_original, schedule_new):
      context = isl.Set("{ : }")
      build = isl.AstBuild.from_context(context)
      schedule_original = schedule_original.intersect_domain(domain)
      schedule_new = schedule_new.intersect_domain(domain)
      print("Before Transform:\n")
      ast = build.node_from_schedule_map(schedule_original)
      printASTAsF(ast, isl.format.C)
      print("After Transform:\n")
      ast = build.node_from_schedule_map(schedule_new)
      printASTAsF(ast, isl.format.C)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [(i // 16) + (i % 16)]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [(i // 16) + (i % 16)]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [(i / 16) + (i % 16)]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [(i / 16) + (i % 16)]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [(i / 16), (i % 16)]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [(i / 16), (i % 16)]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [i / 16, i mod 16]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [i / 16, i mod 16]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> S[i / 16, i mod 16]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> S[i / 16, i mod 16]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [a=i / 16, b=i mod 16]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [a=i / 16, b=i mod 16]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [a=floor(i / 16), b=i mod 16]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (d)
  domain = isl.Set("{S[i]: 0 <= i < 256}")
  schedule = isl.UnionMap("{S[i] -> [a=floor(i / 16), b=i mod 16]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (e)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 256}")
  schedule = isl.UnionMap("{S[i,j] -> [floor(i / 64), floor(j / 64), i mod 64, j mod 64]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (e)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 256}")
  schedule = isl.UnionMap("{S[i,j] -> [floor(i / 64), floor(j / 64), i mod 64, j mod 64]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (e)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 256}")
  schedule = isl.UnionMap("{S[i,j] -> [i mod 64, j mod 64, floor(i / 64), floor(j / 64)]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (e)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 256}")
  schedule = isl.UnionMap("{S[i,j] -> [i mod 64, j mod 64, floor(i / 64), floor(j / 64)]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (e)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 256}")
  schedule = isl.UnionMap("{S[i,j] -> [i mod 16, j mod 16, floor(i / 16), floor(j / 16)]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (e)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 256}")
  schedule = isl.UnionMap("{S[i,j] -> [i mod 16, j mod 16, floor(i / 16), floor(j / 16)]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (e)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 256}")
  schedule = isl.UnionMap("{S[i,j] -> [floor(i / 16), floor(j / 16), i mod 16, j mod 16]}")
  print_code(domain, schedule)

source_raw:
  #Task: 5.1 (e)
  domain = isl.Set("{S[i,j]: 0 <= i,j < 256}")
  schedule = isl.UnionMap("{S[i,j] -> [floor(i / 16), floor(j / 16), i mod 16, j mod 16]}")
  print_code(domain, schedule)


source:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)

source_raw:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)


source:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]: i mod 2 = 0}").union("{T[i,k,j] -> [i,k,3-j]: i mod 2 = 1}")

source_raw:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]: i mod 2 = 0}").union("{T[i,k,j] -> [i,k,3-j]: i mod 2 = 1}")


source:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [i,k,j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{T[i,k,j] -> [i,k,3-j]: i mod 2 = 1}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)

source_raw:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [i,k,j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{T[i,k,j] -> [i,k,3-j]: i mod 2 = 1}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)


source:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [i,k,0,j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{T[i,k,j] -> [i,k,1,3-j]: i mod 2 = 1}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)

source_raw:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [i,k,0,j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{T[i,k,j] -> [i,k,1,3-j]: i mod 2 = 1}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)


source:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [0,i,k,0,j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{T[i,k,j] -> [1,i,k,1,3-j]: i mod 2 = 1}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)

source_raw:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [0,i,k,0,j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{T[i,k,j] -> [1,i,k,1,3-j]: i mod 2 = 1}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)


source:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [i,k,0,3-j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)

source_raw:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [i,k,0,3-j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)


source:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [i,k,0,3-j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{T[i,k,j] -> [i,k,1,3-j]: i mod 2 = 1}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)

source_raw:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [i,k,0,3-j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{T[i,k,j] -> [i,k,1,3-j]: i mod 2 = 1}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)


source:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [i,k,j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{T[i,k,j] -> [i,k,-j]: i mod 2 = 1}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)

source_raw:
  #Task: 5.1 (f)
  domain = isl.Set("{T[i,k,j]: 0 <= i,k,j <= 3}")
  orig_schedule = isl.UnionMap("{T[i,k,j] -> [i,k,j]}")
  print_code(domain, orig_schedule)
  new_schedule_1 = isl.UnionMap("{T[i,k,j] -> [i,k,j]: i mod 2 = 0}")
  new_schedule_2 = isl.UnionMap("{T[i,k,j] -> [i,k,-j]: i mod 2 = 1}")
  new_schedule = new_schedule_1.union(new_schedule_2)
  print_code(domain, new_schedule)


