Case bash on variables in finite intervals #
This file provides the tactic interval_cases. interval_cases n will:
- inspect hypotheses looking for lower and upper bounds of the form
a ≤ nandn < b(inℕ,ℤ,ℕ+, bounds of the forma < nandn ≤ bare also allowed), and also makes use of lower and upper bounds found viale_topandbot_le(so for example ifn : ℕ, then the bound0 ≤ nis automatically found). - call
fin_caseson the synthesised hypothesisn ∈ set.Ico a b, assuming an appropriatefintypeinstance can be found for the type ofn.
The variable n can belong to any type α, with the following restrictions:
- only bounds on which
expr.to_ratsucceeds will be considered "explicit" (TODO: generalise this?) - an instance of
decidable_eq αis available, - an explicit lower bound can be found among the hypotheses, or from
bot_le n, - an explicit upper bound can be found among the hypotheses, or from
le_top n, - if multiple bounds are located, an instance of
linear_order αis available, and - an instance of
fintype set.Ico l uis available for the relevant bounds.
You can also explicitly specify a lower and upper bound to use, as interval_cases using hl hu,
where the hypotheses should be of the form hl : a ≤ n and hu : n < b. In that case,
interval_cases calls fin_cases on the resulting hypothesis h : n ∈ set.Ico a b.
The finset of elements of a set s for which we have fintype s.
Equations
Each element of s is a member of set_elems s.
interval_cases n searches for upper and lower bounds on a variable n,
and if bounds are found,
splits into separate cases for each possible value of n.
As an example, in
example (n : ℕ) (w₁ : n ≥ 3) (w₂ : n < 5) : n = 3 ∨ n = 4 :=
begin
interval_cases n,
all_goals {simp}
end
after interval_cases n, the goals are 3 = 3 ∨ 3 = 4 and 4 = 3 ∨ 4 = 4.
You can also explicitly specify a lower and upper bound to use,
as interval_cases using hl hu.
The hypotheses should be in the form hl : a ≤ n and hu : n < b,
in which case interval_cases calls fin_cases on the resulting fact n ∈ set.Ico a b.
You can also explicitly specify a name to use for the hypothesis added,
as interval_cases n with hn or interval_cases n using hl hu with hn.
In particular, interval_cases n
- inspects hypotheses looking for lower and upper bounds of the form
a ≤ nandn < b(although inℕ,ℤ, andℕ+bounds of the forma < nandn ≤ bare also allowed), and also makes use of lower and upper bounds found viale_topandbot_le(so for example ifn : ℕ, then the bound0 ≤ nis found automatically), then - calls
fin_caseson the synthesised hypothesisn ∈ set.Ico a b, assuming an appropriatefintypeinstance can be found for the type ofn.
The variable n can belong to any type α, with the following restrictions:
- only bounds on which
expr.to_ratsucceeds will be considered "explicit" (TODO: generalise this?) - an instance of
decidable_eq αis available, - an explicit lower bound can be found amongst the hypotheses, or from
bot_le n, - an explicit upper bound can be found amongst the hypotheses, or from
le_top n, - if multiple bounds are located, an instance of
linear_order αis available, and - an instance of
fintype set.Ico l uis available for the relevant bounds.