]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/lib/reverse_complexity/almost.ma
backport of WIP on \lambda\delta to matita 0.99.3
[helm.git] / matita / matita / lib / reverse_complexity / almost.ma
diff --git a/matita/matita/lib/reverse_complexity/almost.ma b/matita/matita/lib/reverse_complexity/almost.ma
new file mode 100644 (file)
index 0000000..75578d0
--- /dev/null
@@ -0,0 +1,24 @@
+include "reverse_complexity/speedup.ma".
+
+definition aes : (nat → nat) → (nat → nat) → Prop ≝ λf,g.
+  ∃n.∀m. n ≤ m → f m = g m.
+
+lemma CF_almost: ∀f,g,s. CF s g → aes g f → CF s f.
+#f #g #s #CFg * #n lapply CFg -CFg lapply g -g
+elim n 
+  [#g #CFg #H @(ext_CF … g) [#m @H // |//]
+  |#i #Hind #g #CFg #H
+   @(Hind (λx. if eqb i x then f i else g x))
+    [@CF_if 
+      [@(O_to_CF … MSC) [@le_to_O @(MSC_in … CFg)] @CF_eqb //
+      |@(O_to_CF … MSC) [@le_to_O @(MSC_in … CFg)] @CF_const
+      |@CFg
+      ]
+    |#m #leim cases (le_to_or_lt_eq … leim)
+      [#ltim lapply (lt_to_not_eq … ltim) #noteqim 
+       >(not_eq_to_eqb_false … noteqim) @H @ltim
+      |#eqim >eqim >eqb_n_n //
+      ]
+    ]
+  ]
+qed.
\ No newline at end of file