]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/library/Z/sigma_p.ma
Reorganization of results.
[helm.git] / matita / library / Z / sigma_p.ma
index b246b8444f0cafed9f6c69a4640b955f8de38b0b..8b4c87d3e4f11e48381ccb0490c8669cc47bb669 100644 (file)
@@ -312,3 +312,317 @@ apply eq_sigma_p
   |intros.apply sym_Ztimes
   ]
 qed.
+
+
+(* sigma from n1*m1 to n2*m2 *)
+theorem sigma_p2_eq: 
+\forall g: nat \to nat \to Z.
+\forall h11,h12,h21,h22: nat \to nat \to nat. 
+\forall n1,m1,n2,m2.
+\forall p11,p21:nat \to bool.
+\forall p12,p22:nat \to nat \to bool.
+(\forall i,j. i < n2 \to j < m2 \to p21 i = true \to p22 i j = true \to 
+p11 (h11 i j) = true \land p12 (h11 i j) (h12 i j) = true
+\land h21 (h11 i j) (h12 i j) = i \land h22 (h11 i j) (h12 i j) = j
+\land h11 i j < n1 \land h12 i j < m1) \to
+(\forall i,j. i < n1 \to j < m1 \to p11 i = true \to p12 i j = true \to 
+p21 (h21 i j) = true \land p22 (h21 i j) (h22 i j) = true
+\land h11 (h21 i j) (h22 i j) = i \land h12 (h21 i j) (h22 i j) = j
+\land (h21 i j) < n2 \land (h22 i j) < m2) \to
+sigma_p n1 p11 (\lambda x:nat .sigma_p m1 (p12 x) (\lambda y. g x y)) =
+sigma_p n2 p21 (\lambda x:nat .sigma_p m2 (p22 x) (\lambda y. g (h11 x y) (h12 x y))).
+intros.
+rewrite < sigma_p2'.
+rewrite < sigma_p2'.
+apply sym_eq.
+letin h := (\lambda x.(h11 (x/m2) (x\mod m2))*m1 + (h12 (x/m2) (x\mod m2))).
+letin h1 := (\lambda x.(h21 (x/m1) (x\mod m1))*m2 + (h22 (x/m1) (x\mod m1))).
+apply (trans_eq ? ? 
+  (sigma_p (n2*m2) (\lambda x:nat.p21 (x/m2)\land p22 (x/m2) (x\mod m2))
+  (\lambda x:nat.g ((h x)/m1) ((h x)\mod m1))))
+  [clear h.clear h1.
+   apply eq_sigma_p1
+    [intros.reflexivity
+    |intros.
+     cut (O < m2)
+      [cut (x/m2 < n2)
+        [cut (x \mod m2 < m2)
+          [elim (and_true ? ? H3).
+           elim (H ? ? Hcut1 Hcut2 H4 H5).
+           elim H6.clear H6.
+           elim H8.clear H8.
+           elim H6.clear H6.
+           elim H8.clear H8.
+           apply eq_f2
+            [apply sym_eq.
+             apply div_plus_times.
+             assumption
+            |autobatch
+            ]
+          |apply lt_mod_m_m.
+           assumption
+          ]
+        |apply (lt_times_n_to_lt m2)
+          [assumption
+          |apply (le_to_lt_to_lt ? x)
+            [apply (eq_plus_to_le ? ? (x \mod m2)).
+             apply div_mod.
+             assumption
+            |assumption
+            ]
+          ]
+        ]
+      |apply not_le_to_lt.unfold.intro.
+       generalize in match H2.
+       apply (le_n_O_elim ? H4).
+       rewrite < times_n_O.
+       apply le_to_not_lt.
+       apply le_O_n  
+      ]      
+    ]
+  |apply (eq_sigma_p_gh ? h h1);intros
+    [cut (O < m2)
+      [cut (i/m2 < n2)
+        [cut (i \mod m2 < m2)
+          [elim (and_true ? ? H3).
+           elim (H ? ? Hcut1 Hcut2 H4 H5).
+           elim H6.clear H6.
+           elim H8.clear H8.
+           elim H6.clear H6.
+           elim H8.clear H8.
+           cut ((h11 (i/m2) (i\mod m2)*m1+h12 (i/m2) (i\mod m2))/m1 = 
+                 h11 (i/m2) (i\mod m2))
+            [cut ((h11 (i/m2) (i\mod m2)*m1+h12 (i/m2) (i\mod m2))\mod m1 =
+                  h12 (i/m2) (i\mod m2))
+              [rewrite > Hcut3.
+               rewrite > Hcut4.
+               rewrite > H6.
+               rewrite > H12.
+               reflexivity
+              |apply mod_plus_times. 
+               assumption
+              ]
+            |apply div_plus_times.
+             assumption
+            ]
+          |apply lt_mod_m_m.
+           assumption
+          ]
+        |apply (lt_times_n_to_lt m2)
+          [assumption
+          |apply (le_to_lt_to_lt ? i)
+            [apply (eq_plus_to_le ? ? (i \mod m2)).
+             apply div_mod.
+             assumption
+            |assumption
+            ]
+          ]
+        ]
+      |apply not_le_to_lt.unfold.intro.
+       generalize in match H2.
+       apply (le_n_O_elim ? H4).
+       rewrite < times_n_O.
+       apply le_to_not_lt.
+       apply le_O_n  
+      ]      
+    |cut (O < m2)
+      [cut (i/m2 < n2)
+        [cut (i \mod m2 < m2)
+          [elim (and_true ? ? H3).
+           elim (H ? ? Hcut1 Hcut2 H4 H5).
+           elim H6.clear H6.
+           elim H8.clear H8.
+           elim H6.clear H6.
+           elim H8.clear H8.
+           cut ((h11 (i/m2) (i\mod m2)*m1+h12 (i/m2) (i\mod m2))/m1 = 
+                 h11 (i/m2) (i\mod m2))
+            [cut ((h11 (i/m2) (i\mod m2)*m1+h12 (i/m2) (i\mod m2))\mod m1 =
+                  h12 (i/m2) (i\mod m2))
+              [rewrite > Hcut3.
+               rewrite > Hcut4.
+               rewrite > H10.
+               rewrite > H11.
+               apply sym_eq.
+               apply div_mod.
+               assumption
+              |apply mod_plus_times. 
+               assumption
+              ]
+            |apply div_plus_times.
+             assumption
+            ]
+          |apply lt_mod_m_m.
+           assumption
+          ]
+        |apply (lt_times_n_to_lt m2)
+          [assumption
+          |apply (le_to_lt_to_lt ? i)
+            [apply (eq_plus_to_le ? ? (i \mod m2)).
+             apply div_mod.
+             assumption
+            |assumption
+            ]
+          ]
+        ]
+      |apply not_le_to_lt.unfold.intro.
+       generalize in match H2.
+       apply (le_n_O_elim ? H4).
+       rewrite < times_n_O.
+       apply le_to_not_lt.
+       apply le_O_n  
+      ]      
+    |cut (O < m2)
+      [cut (i/m2 < n2)
+        [cut (i \mod m2 < m2)
+          [elim (and_true ? ? H3).
+           elim (H ? ? Hcut1 Hcut2 H4 H5).
+           elim H6.clear H6.
+           elim H8.clear H8.
+           elim H6.clear H6.
+           elim H8.clear H8.
+           apply lt_times_plus_times
+            [assumption|assumption]
+          |apply lt_mod_m_m.
+           assumption
+          ]
+        |apply (lt_times_n_to_lt m2)
+          [assumption
+          |apply (le_to_lt_to_lt ? i)
+            [apply (eq_plus_to_le ? ? (i \mod m2)).
+             apply div_mod.
+             assumption
+            |assumption
+            ]
+          ]
+        ]
+      |apply not_le_to_lt.unfold.intro.
+       generalize in match H2.
+       apply (le_n_O_elim ? H4).
+       rewrite < times_n_O.
+       apply le_to_not_lt.
+       apply le_O_n  
+      ]
+    |cut (O < m1)
+      [cut (j/m1 < n1)
+        [cut (j \mod m1 < m1)
+          [elim (and_true ? ? H3).
+           elim (H1 ? ? Hcut1 Hcut2 H4 H5).
+           elim H6.clear H6.
+           elim H8.clear H8.
+           elim H6.clear H6.
+           elim H8.clear H8.
+           cut ((h21 (j/m1) (j\mod m1)*m2+h22 (j/m1) (j\mod m1))/m2 = 
+                 h21 (j/m1) (j\mod m1))
+            [cut ((h21 (j/m1) (j\mod m1)*m2+h22 (j/m1) (j\mod m1))\mod m2 =
+                  h22 (j/m1) (j\mod m1))
+              [rewrite > Hcut3.
+               rewrite > Hcut4.
+               rewrite > H6.
+               rewrite > H12.
+               reflexivity
+              |apply mod_plus_times. 
+               assumption
+              ]
+            |apply div_plus_times.
+             assumption
+            ]
+          |apply lt_mod_m_m.
+           assumption
+          ] 
+        |apply (lt_times_n_to_lt m1)
+          [assumption
+          |apply (le_to_lt_to_lt ? j)
+            [apply (eq_plus_to_le ? ? (j \mod m1)).
+             apply div_mod.
+             assumption
+            |assumption
+            ]
+          ]
+        ]
+      |apply not_le_to_lt.unfold.intro.
+       generalize in match H2.
+       apply (le_n_O_elim ? H4).
+       rewrite < times_n_O.
+       apply le_to_not_lt.
+       apply le_O_n  
+      ] 
+    |cut (O < m1)
+      [cut (j/m1 < n1)
+        [cut (j \mod m1 < m1)
+          [elim (and_true ? ? H3).
+           elim (H1 ? ? Hcut1 Hcut2 H4 H5).
+           elim H6.clear H6.
+           elim H8.clear H8.
+           elim H6.clear H6.
+           elim H8.clear H8.
+           cut ((h21 (j/m1) (j\mod m1)*m2+h22 (j/m1) (j\mod m1))/m2 = 
+                 h21 (j/m1) (j\mod m1))
+            [cut ((h21 (j/m1) (j\mod m1)*m2+h22 (j/m1) (j\mod m1))\mod m2 =
+                  h22 (j/m1) (j\mod m1))
+              [rewrite > Hcut3.
+               rewrite > Hcut4.               
+               rewrite > H10.
+               rewrite > H11.
+               apply sym_eq.
+               apply div_mod.
+               assumption
+              |apply mod_plus_times. 
+               assumption
+              ]
+            |apply div_plus_times.
+             assumption
+            ]
+          |apply lt_mod_m_m.
+           assumption
+          ] 
+        |apply (lt_times_n_to_lt m1)
+          [assumption
+          |apply (le_to_lt_to_lt ? j)
+            [apply (eq_plus_to_le ? ? (j \mod m1)).
+             apply div_mod.
+             assumption
+            |assumption
+            ]
+          ]
+        ]
+      |apply not_le_to_lt.unfold.intro.
+       generalize in match H2.
+       apply (le_n_O_elim ? H4).
+       rewrite < times_n_O.
+       apply le_to_not_lt.
+       apply le_O_n  
+      ] 
+    |cut (O < m1)
+      [cut (j/m1 < n1)
+        [cut (j \mod m1 < m1)
+          [elim (and_true ? ? H3).
+           elim (H1 ? ? Hcut1 Hcut2 H4 H5).
+           elim H6.clear H6.
+           elim H8.clear H8.
+           elim H6.clear H6.
+           elim H8.clear H8.
+           apply (lt_times_plus_times ? ? ? m2)
+            [assumption|assumption]
+          |apply lt_mod_m_m.
+           assumption
+          ] 
+        |apply (lt_times_n_to_lt m1)
+          [assumption
+          |apply (le_to_lt_to_lt ? j)
+            [apply (eq_plus_to_le ? ? (j \mod m1)).
+             apply div_mod.
+             assumption
+            |assumption
+            ]
+          ]
+        ]
+      |apply not_le_to_lt.unfold.intro.
+       generalize in match H2.
+       apply (le_n_O_elim ? H4).
+       rewrite < times_n_O.
+       apply le_to_not_lt.
+       apply le_O_n  
+      ]
+    ]
+  ]
+qed.
\ No newline at end of file