Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit c1e594b

Browse files
bryangingechendigama0
authored andcommitted
feat(meta, logic, tactic): lean 3.4.2: migrate coinductive_predicates, transfer, relator (#610)
1 parent 2c5bc21 commit c1e594b

File tree

9 files changed

+992
-9
lines changed

9 files changed

+992
-9
lines changed

leanpkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "mathlib"
33
version = "0.1"
4-
lean_version = "3.4.1"
4+
lean_version = "3.4.2"
55
path = "src"
66

77
[dependencies]

src/data/list/defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, M
55
66
Extra definitions on lists.
77
-/
8-
import data.option.defs logic.basic
8+
import data.option.defs logic.basic logic.relator
99

1010
namespace list
1111

src/logic/relator.lean

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,88 @@
11
/-
2-
Copyright (c) 2018 Johannes Hölzl. All rights reserved.
2+
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johannes Hölzl
55
6-
This is an extension of `init/relator.lean`
6+
Relator for functions, pairs, sums, and lists.
77
-/
8-
variables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}
9-
variables {r : α → β → Prop} {p : β → γ → Prop} {q : γ → δ → Prop}
8+
9+
prelude
10+
import init.core init.data.basic
1011

1112
namespace relator
13+
universe variables u₁ u₂ v₁ v₂
14+
15+
reserve infixr ` ⇒ `:40
16+
17+
/- TODO(johoelzl):
18+
* should we introduce relators of datatypes as recursive function or as inductive
19+
predicate? For now we stick to the recursor approach.
20+
* relation lift for datatypes, Π, Σ, set, and subtype types
21+
* proof composition and identity laws
22+
* implement method to derive relators from datatype
23+
-/
24+
25+
section
26+
variables {α : Type u₁} {β : Type u₂} {γ : Type v₁} {δ : Type v₂}
27+
variables (R : α → β → Prop) (S : γ → δ → Prop)
28+
29+
def lift_fun (f : α → γ) (g : β → δ) : Prop :=
30+
∀{a b}, R a b → S (f a) (g b)
31+
32+
infixr ⇒ := lift_fun
33+
34+
end
35+
36+
section
37+
variables {α : Type u₁} {β : out_param $ Type u₂} (R : out_param $ α → β → Prop)
38+
39+
@[class] def right_total := ∀b, ∃a, R a b
40+
@[class] def left_total := ∀a, ∃b, R a b
41+
@[class] def bi_total := left_total R ∧ right_total R
42+
43+
end
44+
45+
section
46+
variables {α : Type u₁} {β : Type u₂} (R : α → β → Prop)
47+
48+
@[class] def left_unique := ∀{a b c}, R a b → R c b → a = c
49+
@[class] def right_unique := ∀{a b c}, R a b → R a c → b = c
50+
51+
lemma rel_forall_of_right_total [t : right_total R] : ((R ⇒ implies) ⇒ implies) (λp, ∀i, p i) (λq, ∀i, q i) :=
52+
assume p q Hrel H b, exists.elim (t b) (assume a Rab, Hrel Rab (H _))
53+
54+
lemma rel_exists_of_left_total [t : left_total R] : ((R ⇒ implies) ⇒ implies) (λp, ∃i, p i) (λq, ∃i, q i) :=
55+
assume p q Hrel ⟨a, pa⟩, let ⟨b, Rab⟩ := t a in ⟨b, Hrel Rab pa⟩
56+
57+
lemma rel_forall_of_total [t : bi_total R] : ((R ⇒ iff) ⇒ iff) (λp, ∀i, p i) (λq, ∀i, q i) :=
58+
assume p q Hrel,
59+
⟨assume H b, exists.elim (t.right b) (assume a Rab, (Hrel Rab).mp (H _)),
60+
assume H a, exists.elim (t.left a) (assume b Rab, (Hrel Rab).mpr (H _))⟩
61+
62+
lemma rel_exists_of_total [t : bi_total R] : ((R ⇒ iff) ⇒ iff) (λp, ∃i, p i) (λq, ∃i, q i) :=
63+
assume p q Hrel,
64+
⟨assume ⟨a, pa⟩, let ⟨b, Rab⟩ := t.left a in ⟨b, (Hrel Rab).1 pa⟩,
65+
assume ⟨b, qb⟩, let ⟨a, Rab⟩ := t.right b in ⟨a, (Hrel Rab).2 qb⟩⟩
66+
67+
lemma left_unique_of_rel_eq {eq' : β → β → Prop} (he : (R ⇒ (R ⇒ iff)) eq eq') : left_unique R
68+
| a b c (ab : R a b) (cb : R c b) :=
69+
have eq' b b,
70+
from iff.mp (he ab ab) rfl,
71+
iff.mpr (he ab cb) this
72+
73+
end
74+
75+
lemma rel_imp : (iff ⇒ (iff ⇒ iff)) implies implies :=
76+
assume p q h r s l, imp_congr h l
77+
78+
lemma rel_not : (iff ⇒ iff) not not :=
79+
assume p q h, not_congr h
80+
81+
instance bi_total_eq {α : Type u₁} : relator.bi_total (@eq α) :=
82+
⟨assume a, ⟨a, rfl⟩, assume a, ⟨a, rfl⟩⟩
83+
84+
variables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}
85+
variables {r : α → β → Prop} {p : β → γ → Prop} {q : γ → δ → Prop}
1286

1387
def bi_unique (r : α → β → Prop) : Prop := left_unique r ∧ right_unique r
1488

0 commit comments

Comments
 (0)