lift tactic #
This file defines the lift tactic, allowing the user to lift elements from one type to another
under a specified condition.
Tags #
lift, tactic
Enable automatic handling of pi types in CanLift.
lift e to t with x lifts the expression e to the type t by introducing a new variable x : t
such that ↑x = e, and then replacing occurrences of e with ↑x. lift requires an instance of
the class CanLift t' t coe cond, where t' is the type of e, and creates a side goal for the
lifting condition, of the form ⊢ cond x, placing this on top of the goal stack.
Given an instance CanLift β γ, lift can also lift α → β to α → γ; more generally, given
β : Π a : α, Type*, γ : Π a : α, Type*, and [Π a : α, CanLift (β a) (γ a)], it
automatically generates an instance CanLift (Π a, β a) (Π a, γ a).
lift is in some sense dual to the zify tactic. lift (z : ℤ) to ℕ will change the type of an
integer z (in the supertype) to ℕ (the subtype), given a proof that z ≥ 0;
propositions concerning z will still be over ℤ. zify changes propositions about ℕ (the
subtype) to propositions about ℤ (the supertype), without changing the type of any variable.
The norm_cast tactic can be used after lift to normalize introduced casts.
lift e to t using h with xuses the expressionhto prove the lifting conditioncond e. Ifhis a variable,liftwill try to clear it from the context. If you want to keephin the context, writelift e to t using h with x rfl h(see below).- If
eis a variable,lift e to tis equivalent tolift e to t with e. The original variableewill be cleared from the context. lift e to t with x hxaddshx : ↑x = eto the context (and ifeis a variable, does not clear it).lift e to t with x hx haddshx : ↑x = eandh : cond eto the context (and ifeis a variable, does not clear it). In particular,lift e to t using h with x hx h, wherehis a variable, keepshin the context.lift e to t with x rfl haddsh : cond eto the context (and ifeis a variable, does not clear it). In particular,lift e to t using h with x rfl h, wherehis a variable, keepshin the context.
Examples:
def P (n : ℤ) : Prop := n = 3
example (n : ℤ) (h : P n) : n = 3 := by
lift n to ℕ
/-
Two goals:
n : ℤ, h : P n ⊢ n ≥ 0
n : ℕ, h : P ↑n ⊢ ↑n = 3
-/
· unfold P at h; linarith
· exact h
example (n : ℤ) (hn : n ≥ 0) (h : P n) : n = 3 := by
lift n to ℕ using hn
/-
One goal:
n : ℕ
h : P ↑n
⊢ ↑n = 3
-/
exact h
example (n : ℤ) (hn : n + 3 ≥ 0) (h : P (n + 3)) :
n + 3 = n * 2 + 3 := by
lift n + 3 to ℕ using hn with k hk
/-
One goal:
n : ℤ
k : ℕ
hk : ↑k = n + 3
h : P ↑k
⊢ ↑k = 2 * n + 3
-/
unfold P at h; linarith
Equations
- One or more equations did not get rendered due to their size.
Instances For
Generate instance for the lift tactic.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Main function for the lift tactic.
Equations
- One or more equations did not get rendered due to their size.