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.
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.
- out : p
Instances
In most cases, we should not have global instances of Fact; typeclass search is not an
advanced proof search engine, and adding any such instance has the potential to cause
slowdowns everywhere. We instead declare them as lemmata and make them local instances as required.
Instances For
Swaps two pairs of arguments to a function.
Instances For
Declarations about propositional connectives #
Declarations about implies #
Alias of Classical.imp_iff_right_iff.
Alias of Classical.and_or_imp.
Provide modus tollens (mt) as dot notation for implications.
In most of mathlib, we use the law of excluded middle (LEM) and the axiom of choice (AC) freely.
The Decidable namespace contains versions of lemmas from the root namespace that explicitly
attempt to avoid the axiom of choice, usually by adding decidability assumptions on the inputs.
You can check if a lemma uses the axiom of choice by using #print axioms foo and seeing if
Classical.choice appears in the list.
Instances For
As mathlib is primarily classical,
if the type signature of a def or lemma does not require any Decidable instances to state,
it is preferable not to introduce any Decidable instances that are needed in the proof
as arguments, but rather to use the classical tactic as needed.
In the other direction, when Decidable instances do appear in the type signature,
it is better to use explicitly introduced ones rather than allowing Lean to automatically infer
classical ones, as these may cause instance mismatch errors later.
Various types that (almost) never have provable decidability, such as ℝ, Set α or Ideal R,
are given global DecidableEq instances, so that no decidable arguments have to be provided.
Instances For
Alias of Decidable.not_imp_symm.
Alias of the forward direction of and_rotate.
Provide the reverse of modus tollens (mt) as dot notation for implications.
Declarations about distributivity #
Declarations about iff
Alias of Classical.not_imp.
De Morgan's laws #
One of de Morgan's laws: the negation of a conjunction is logically equivalent to the disjunction of the negations.
Declarations about equality #
Alias of ne_of_eq_of_ne.
Alias of ne_of_ne_of_eq.
Declarations about quantifiers #
Alias of forall_comm.
Alias of forall₂_comm.
We intentionally restrict the type of α in this lemma so that this is a safer to use in simp
than forall_comm.
Alias of exists_comm.
The constant function witnesses that there exists a function sending a given term to a given term.
This is sometimes useful in simp to discharge side conditions.
See IsEmpty.forall_iff for the False version.
Classical lemmas #
Any prop p is decidable classically. A shorthand for Classical.propDecidable.
Instances For
Any predicate p is decidable classically.
Instances For
Any relation p is decidable classically.
Instances For
Any type α has decidable equality classically.
Instances For
Construct a function from a default value H0, and a function to use if there exists a value
satisfying the predicate.
Instances For
A version of byContradiction that uses types instead of propositions.
Instances For
Classical.byContradiction' is equivalent to lean's axiom Classical.choice.
Instances For
Alias of Classical.axiomOfChoice.
Alias of Classical.byCases.
Alias of Classical.byContradiction.
Alias of Classical.propComplete.
This function has the same type as Exists.recOn, and can be used to case on an equality,
but Exists.recOn can only eliminate into Prop, while this version eliminates into any universe
using the axiom of choice.
Instances For
Declarations about bounded quantifiers #
A two-argument function applied to two dites is a dite of that two-argument function
applied to each of the branches.
A two-argument function applied to two ites is a ite of that two-argument function
applied to each of the branches.
A 'dite' producing a Pi type Π a, σ a, applied to a value a : α is a dite that applies
either branch to a.
Membership #
Alias of ne_of_mem_of_not_mem.
Alias of ne_of_mem_of_not_mem'.
Alias of Bool.beq_eq_decide_eq.