Basic logic properties #
This file is one of the earliest imports in mathlib.
Implementation notes #
Theorems that require decidability hypotheses are in the namespace "decidable". Classical versions are in the namespace "classical".
In the presence of automation, this whole file may be unnecessary. On the other hand, maybe it is useful for writing automation.
Ex falso, the nondependent eliminator for the empty
type.
Equations
- empty.decidable_eq = λ (a : empty), a.elim
Equations
- sort.inhabited = {default := punit}
Equations
Equations
If all points are equal to a given point x
, then α
is a subsingleton.
Non-dependent version of coe_fn_coe_trans
, helps rw
figure out the argument.
Non-dependent version of coe_fn_coe_base
, helps rw
figure out the argument.
Ex falso, the nondependent eliminator for the pempty
type.
- out : p
Wrapper for adding elementary propositions to the type class systems. Warning: this can easily be abused. See the rest of this docstring for details.
Certain propositions should not be treated as a class globally, but sometimes it is very convenient to be able to use the type class system in specific circumstances.
For example, zmod p
is a field if and only if p
is a prime number.
In order to be able to find this field instance automatically by type class search,
we have to turn p.prime
into an instance implicit assumption.
On the other hand, making nat.prime
a class would require a major refactoring of the library,
and it is questionable whether making nat.prime
a class is desirable at all.
The compromise is to add the assumption [fact p.prime]
to zmod.field
.
In particular, this class is not intended for turning the type class system into an automated theorem prover for first order logic.
Swaps two pairs of arguments to a function.
Equations
- function.swap₂ f = λ (i₂ : ι₂) (j₂ : κ₂ i₂) (i₁ : ι₁) (j₁ : κ₁ i₁), f i₁ j₁ i₂ j₂
Declarations about propositional connectives #
Declarations about distributivity #
Declarations about iff
Transfer decidability of b
to decidability of a
, if the propositions are equivalent.
This is the same as decidable_of_iff
but the iff is flipped.
Equations
Prove that a
is decidable by constructing a boolean b
and a proof that b ↔ a
.
(This is sometimes taken as an alternate definition of decidability.)
Equations
- decidable_of_bool tt h = is_true _
- decidable_of_bool ff h = is_false _
De Morgan's laws #
Declarations about equality #
Alias of ne_of_mem_of_not_mem
.
Transport through trivial families is the identity.
Declarations about quantifiers #
We intentionally restrict the type of α
in this lemma so that this is a safer to use in simp
than forall_swap
.
Extract an element from a existential statement, using classical.some
.
Equations
- P.some = classical.some P
Show that an element extracted from P : ∃ a, p a
using P.some
satisfies p
.
Classical lemmas #
Any prop p
is decidable classically. A shorthand for classical.prop_decidable
.
Equations
Any predicate p
is decidable classically.
Equations
- classical.dec_pred p = λ (a : α), classical.prop_decidable (p a)
Any relation p
is decidable classically.
Equations
- classical.dec_rel p = λ (a b : α), classical.prop_decidable (p a b)
Any type α
has decidable equality classically.
Equations
- classical.dec_eq α = λ (a b : α), classical.prop_decidable (a = b)
Construct a function from a default value H0
, and a function to use if there exists a value
satisfying the predicate.
Equations
- classical.exists_cases H0 H = dite (∃ (a : α), p a) (λ (h : ∃ (a : α), p a), H (classical.some h) _) (λ (h : ¬∃ (a : α), p a), H0)
A version of classical.indefinite_description which is definitionally equal to a pair
Equations
classical.by_contradiction'
is equivalent to lean's axiom classical.choice
.
Equations
- classical.choice_of_by_contradiction' contra = λ (H : nonempty α), contra _
This function has the same type as exists.rec_on
, and can be used to case on an equality,
but exists.rec_on
can only eliminate into Prop, while this version eliminates into any universe
using the axiom of choice.
Equations
- exists.classical_rec_on h H = H (classical.some h) _
Declarations about bounded quantifiers #
A 'dite' producing a Pi
type Π a, σ a
, applied to a value a : α
is a dite
that applies
either branch to a
.