A tactic for canceling numeric denominators #
This file defines tactics that cancel numeric denominators from field Expressions.
As an example, we want to transform a comparison 5*(a/3 + b/4) < c/3
into the equivalent
5*(4*a + 3*b) < 4*c
.
Implementation notes #
The tooling here was originally written for linarith
, not intended as an interactive tactic.
The interactive version has been split off because it is sometimes convenient to use on its own.
There are likely some rough edges to it.
Improving this tactic would be a good project for someone interested in learning tactic programming.
Lemmas used in the procedure #
Computing cancellation factors #
findCancelFactor e
produces a natural number n
, such that multiplying e
by n
will
be able to cancel all the numeric denominators in e
. The returned Tree
describes how to
distribute the value n
over products inside e
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
CancelResult mα e v'
provies a value for v * e
where the denominators have been cancelled.
- cancelled : Q(«$α»)
An expression with denominators cancelled.
The proof that
cancelled
is valid.
Instances For
mkProdPrf α sα v v' tr e
produces a proof of v'*e = e'
, where numeric denominators have been
canceled in e'
, distributing v
proportionally according to the tree tr
computed
by findCancelFactor
.
The v'
argument is a numeral expression corresponding to v
, which we need in order to state
the return type accurately.
Theorems to get expression into a form that findCancelFactor
and mkProdPrf
can more easily handle. These are important for dividing by rationals and negative integers.
Equations
- CancelDenoms.deriveThms = [`div_div_eq_mul_div, `div_neg]
Instances For
Given e
, a term with rational division, produces a natural number n
and a proof of n*e = e'
,
where e'
has no division. Assumes "well-behaved" division.
Equations
- One or more equations did not get rendered due to their size.
Instances For
findCompLemma e
arranges e
in the form lhs R rhs
, where R ∈ {<, ≤, =, ≠}
, and returns
lhs
, rhs
, the cancel_factors
lemma corresponding to R
, and a boolean indicating whether
R
involves the order (i.e. <
and ≤
) or not (i.e. =
and ≠
).
In the case of LT
, LE
, GE
, and GT
an order on the type is needed, in the last case
it is not, the final component of the return value tracks this.
Equations
- One or more equations did not get rendered due to their size.
Instances For
cancelDenominatorsInType h
assumes that h
is of the form lhs R rhs
,
where R ∈ {<, ≤, =, ≠, ≥, >}
.
It produces an Expression h'
of the form lhs' R rhs'
and a proof that h = h'
.
Numeric denominators have been canceled in lhs'
and rhs'
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
cancel_denoms
attempts to remove numerals from the denominators of fractions.
It works on propositions that are field-valued inequalities.
variable [LinearOrderedField α] (a b c : α)
example (h : a / 5 + b / 4 < c) : 4*a + 5*b < 20*c := by
cancel_denoms at h
exact h
example (h : a > 0) : a / 5 > 0 := by
cancel_denoms
exact h
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.