@@ -44,32 +44,48 @@ open Lean.Parser.Tactic
4444open Lean.Elab.Tactic
4545
4646/--
47- The `rify` tactic is used to shift propositions from `ℕ`, `ℤ` or `ℚ ` to `ℝ`.
47+ `rify` rewrites the main goal by shifting propositions from `ℕ`, `ℤ`, `ℚ` or `ℝ≥0 ` to `ℝ`.
4848Although less useful than its cousins `zify` and `qify`, it can be useful when your
4949goal or context already involves real numbers.
5050
51- In the example below, assumption `hn` is about natural numbers, `hk` is about integers
52- and involves casting a natural number to `ℤ`, and the conclusion is about real numbers.
53- The proof uses `rify` to lift both assumptions to `ℝ` before calling `linarith`.
51+ `rify` makes use of the `@[zify_simps]`, `@[qify_simps]` and `@[rify_simps]` attributes to insert
52+ casts into propositions, and the `push_cast` tactic to simplify the `ℝ`-valued expressions.
53+
54+ `rify` is in some sense dual to the `lift` tactic. `lift (r : ℝ) to ℚ` will change the type of a
55+ real number `r` (in the supertype) to `ℚ` (the subtype), given a proof that `r` is rational;
56+ propositions concerning `r` will still be over `ℝ`. `rify` changes propositions about `ℕ`, `ℤ`, `ℚ`
57+ or `ℝ≥0` (the subtype) to propositions about `ℝ` (the supertype), without changing the type of any
58+ variable.
59+
60+ * `rify at l1 l2 ...` rewrites at the given locations.
61+ * `rify [h₁, ..., hₙ]` uses the expressions `h₁`, ..., `hₙ` as extra lemmas for simplification.
62+ This is especially useful in the presence of nat subtraction or of division: passing arguments of
63+ type `· ≤ ·` or `· ∣ ·` will allow `push_cast` to do more work.
64+
65+ Examples:
5466```
67+ /--
68+ import Mathlib
69+
70+ open Real
71+ Here, the assumption `hn` is about natural numbers, `hk` is about integers
72+ and involves casting a natural number to `ℤ`, and the conclusion is about real numbers.
73+ -/
5574example {n : ℕ} {k : ℤ} (hn : 8 ≤ n) (hk : 2 * k ≤ n + 2) :
5675 (0 : ℝ) < n - k - 1 := by
5776 rify at hn hk /- Now have hn : 8 ≤ (n : ℝ) hk : 2 * (k : ℝ) ≤ (n : ℝ) + 2 -/
5877 linarith
59- ```
60-
61- `rify` makes use of the `@[zify_simps]`, `@[qify_simps]` and `@[rify_simps]` attributes to move
62- propositions, and the `push_cast` tactic to simplify the `ℝ`-valued expressions.
6378
64- `rify` can be given extra lemmas to use in simplification. This is especially useful in the
65- presence of nat subtraction: passing `≤` arguments will allow `push_cast` to do more work.
66- ```
79+ -- Extra hypotheses allow `push_cast` to do more work.
6780example (a b c : ℕ) (h : a - b < c) (hab : b ≤ a) : a < b + c := by
68- rify [hab] at h ⊢
81+ rify [hab] at h ⊢ -- Here `zify` or `qify` would have also worked.
6982 linarith
83+
84+ example (a b : ℕ) (ha : π ≤ a) : 3 ≤ a + b := by
85+ rify
86+ linarith [pi_gt_three]
7087```
71- Note that `zify` or `qify` would work just as well in the above example (and `zify` is the natural
72- choice since it is enough to get rid of the pathological `ℕ` subtraction). -/
88+ -/
7389syntax (name := rify) "rify" (simpArgs)? (location)? : tactic
7490
7591macro_rules
0 commit comments