Skip to content

Commit 5f625c1

Browse files
authored
Merge branch 'master' into wojciech/treemap_beq
2 parents b503c77 + f8866dc commit 5f625c1

File tree

328 files changed

+72009
-35220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

328 files changed

+72009
-35220
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
4444
set(CADICAL_CXX c++)
4545
if (CADICAL_USE_CUSTOM_CXX)
4646
set(CADICAL_CXX ${CMAKE_CXX_COMPILER})
47-
set(CADICAL_CXXFLAGS "${LEAN_EXTRA_CXX_FLAGS}")
47+
# Use same platform flags as for Lean executables, in particular from `prepare-llvm-linux.sh`,
48+
# but not Lean-specific `LEAN_EXTRA_CXX_FLAGS` such as fsanitize.
49+
set(CADICAL_CXXFLAGS "${CMAKE_CXX_FLAGS}")
4850
set(CADICAL_LDFLAGS "-Wl,-rpath=\\$$ORIGIN/../lib")
4951
endif()
5052
find_program(CCACHE ccache)

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ if(LLVM AND ${STAGE} GREATER 0)
448448
# - In particular, `host/bin/llvm-config` produces flags like `-Lllvm-host/lib/libLLVM`, while
449449
# we need the path to be `-Lllvm/lib/libLLVM`. Thus, we perform this replacement here.
450450
string(REPLACE "llvm-host" "llvm" LEANSHARED_LINKER_FLAGS ${LEANSHARED_LINKER_FLAGS})
451-
string(REPLACE "llvm-host" "llvm" LEAN_EXTRA_CXX_FLAGS ${LEAN_EXTRA_CXX_FLAGS})
452-
message(VERBOSE "leanshared linker flags: '${LEANSHARED_LINKER_FLAGS}' | lean extra cxx flags '${LEAN_EXTR_CXX_FLAGS}'")
451+
string(REPLACE "llvm-host" "llvm" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
452+
message(VERBOSE "leanshared linker flags: '${LEANSHARED_LINKER_FLAGS}' | lean extra cxx flags '${CMAKE_CXX_FLAGS}'")
453453
endif()
454454

455455
# get rid of unused parts of C++ stdlib

src/Init/Data/Int/Basic.lean

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,11 @@ set_option bootstrap.genMatcherCode false in
278278
def decNonneg (m : @& Int) : Decidable (NonNeg m) :=
279279
match m with
280280
| ofNat m => isTrue <| NonNeg.mk m
281-
| -[_ +1] => isFalse <| fun h => nomatch h
281+
| -[i +1] => isFalse <| fun h =>
282+
have : ∀ j, (j = -[i +1]) → NonNeg j → False := fun _ hj hnn =>
283+
Int.NonNeg.casesOn (motive := fun j _ => j = -[i +1] → False) hnn
284+
(fun _ h => Int.noConfusion h) hj
285+
this -[i +1] rfl h
282286

283287
/-- Decides whether `a ≤ b`.
284288

src/Init/Data/List/Nat/Perm.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ theorem set_set_perm {as : List α} {i j : Nat} (h₁ : i < as.length) (h₂ : j
6060

6161
namespace Perm
6262

63-
/-- Variant of `List.Perm.take` specifying the the permutation is constant after `i` elementwise. -/
63+
/-- Variant of `List.Perm.take` specifying that the permutation is constant after `i` elementwise. -/
6464
theorem take_of_getElem? {l₁ l₂ : List α} (h : l₁ ~ l₂) {i : Nat} (w : ∀ j, i ≤ j → l₁[j]? = l₂[j]?) :
6565
l₁.take i ~ l₂.take i := by
6666
refine h.take (Perm.of_eq ?_)
6767
ext1 j
6868
simpa using w (i + j) (by omega)
6969

70-
/-- Variant of `List.Perm.drop` specifying the the permutation is constant before `i` elementwise. -/
70+
/-- Variant of `List.Perm.drop` specifying that the permutation is constant before `i` elementwise. -/
7171
theorem drop_of_getElem? {l₁ l₂ : List α} (h : l₁ ~ l₂) {i : Nat} (w : ∀ j, j < i → l₁[j]? = l₂[j]?) :
7272
l₁.drop i ~ l₂.drop i := by
7373
refine h.drop (Perm.of_eq ?_)

src/Init/Data/Slice/Notation.lean

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ prelude
99
public import Init.Data.Range.Polymorphic.PRange
1010

1111
set_option doc.verso true
12+
set_option linter.missingDocs true
1213

1314
public section
1415

@@ -30,6 +31,9 @@ This typeclass indicates how to obtain slices of elements of {lit}`α` over rang
3031
The type of the resulting slices is {lit}`γ`.
3132
-/
3233
class Rcc.Sliceable (α : Type u) (β : outParam (Type v)) (γ : outParam (Type w)) where
34+
/--
35+
Slices {name}`carrier` from {lean}`range.lower` to {lean}`range.upper`, both inclusive.
36+
-/
3337
mkSlice (carrier : α) (range : Rcc β) : γ
3438

3539
/--
@@ -39,6 +43,9 @@ This typeclass indicates how to obtain slices of elements of {lit}`α` over rang
3943
The type of resulting the slices is {lit}`γ`.
4044
-/
4145
class Rco.Sliceable (α : Type u) (β : outParam (Type v)) (γ : outParam (Type w)) where
46+
/--
47+
Slices {name}`carrier` from {lean}`range.lower` (inclusive) to {lean}`range.upper` (exclusive).
48+
-/
4249
mkSlice (carrier : α) (range : Rco β) : γ
4350

4451
/--
@@ -48,6 +55,9 @@ This typeclass indicates how to obtain slices of elements of {lit}`α` over rang
4855
The type of the resulting slices is {lit}`γ`.
4956
-/
5057
class Rci.Sliceable (α : Type u) (β : outParam (Type v)) (γ : outParam (Type w)) where
58+
/--
59+
Slices {name}`carrier` from {lean}`range.lower` (inclusive).
60+
-/
5161
mkSlice (carrier : α) (range : Rci β) : γ
5262

5363
/--
@@ -57,6 +67,9 @@ This typeclass indicates how to obtain slices of elements of {lit}`α` over rang
5767
The type of the resulting slices is {lit}`γ`.
5868
-/
5969
class Roc.Sliceable (α : Type u) (β : outParam (Type v)) (γ : outParam (Type w)) where
70+
/--
71+
Slices {name}`carrier` from {lean}`range.lower` (exclusive) to {lean}`range.upper` (inclusive).
72+
-/
6073
mkSlice (carrier : α) (range : Roc β) : γ
6174

6275
/--
@@ -66,6 +79,9 @@ This typeclass indicates how to obtain slices of elements of {lit}`α` over rang
6679
The type of the resulting slices is {lit}`γ`.
6780
-/
6881
class Roo.Sliceable (α : Type u) (β : outParam (Type v)) (γ : outParam (Type w)) where
82+
/--
83+
Slices {name}`carrier` from {lean}`range.lower` to {lean}`range.upper`, both exclusive.
84+
-/
6985
mkSlice (carrier : α) (range : Roo β) : γ
7086

7187
/--
@@ -75,6 +91,9 @@ This typeclass indicates how to obtain slices of elements of {lit}`α` over rang
7591
The type of the resulting slices is {lit}`γ`.
7692
-/
7793
class Roi.Sliceable (α : Type u) (β : outParam (Type v)) (γ : outParam (Type w)) where
94+
/--
95+
Slices {name}`carrier` from {lean}`range.lower` (exclusive).
96+
-/
7897
mkSlice (carrier : α) (range : Roi β) : γ
7998

8099
/--
@@ -84,6 +103,9 @@ This typeclass indicates how to obtain slices of elements of {lit}`α` over rang
84103
The type of the resulting slices is {lit}`γ`.
85104
-/
86105
class Ric.Sliceable (α : Type u) (β : outParam (Type v)) (γ : outParam (Type w)) where
106+
/--
107+
Slices {name}`carrier` up to {lean}`range.upper` (inclusive).
108+
-/
87109
mkSlice (carrier : α) (range : Ric β) : γ
88110

89111
/--
@@ -93,6 +115,9 @@ This typeclass indicates how to obtain slices of elements of {lit}`α` over rang
93115
The type of the resulting slices is {lit}`γ`.
94116
-/
95117
class Rio.Sliceable (α : Type u) (β : outParam (Type v)) (γ : outParam (Type w)) where
118+
/--
119+
Slices {name}`carrier` up to {lean}`range.upper` (exclusive).
120+
-/
96121
mkSlice (carrier : α) (range : Rio β) : γ
97122

98123
/--
@@ -102,6 +127,9 @@ index type {lit}`β`.
102127
The type of the resulting slices is {lit}`γ`.
103128
-/
104129
class Rii.Sliceable (α : Type u) (β : outParam (Type v)) (γ : outParam (Type w)) where
130+
/--
131+
Slices {name}`carrier` with no bounds.
132+
-/
105133
mkSlice (carrier : α) (range : Rii β) : γ
106134

107135
macro_rules

src/Init/Data/Sum/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public section
1313
/-!
1414
# Disjoint union of types
1515
16-
This file defines basic operations on the the sum type `α ⊕ β`.
16+
This file defines basic operations on the sum type `α ⊕ β`.
1717
1818
`α ⊕ β` is the type made of a copy of `α` and a copy of `β`. It is also called *disjoint union*.
1919

src/Init/GetElem.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ theorem getElem_of_getElem? [GetElem? cont idx elem dom] [LawfulGetElem cont idx
240240
{c : cont} {i : idx} [Decidable (dom c i)] (h : c[i]? = some e) : Exists fun h : dom c i => c[i] = e :=
241241
getElem?_eq_some_iff.mp h
242242

243+
theorem of_getElem_eq [GetElem? cont idx elem dom] [LawfulGetElem cont idx elem dom]
244+
{c : cont} {i : idx} [Decidable (dom c i)] {h} (_ : c[i] = e) : dom c i := h
245+
243246
@[simp] theorem some_getElem_eq_getElem?_iff [GetElem? cont idx elem dom] [LawfulGetElem cont idx elem dom]
244247
{c : cont} {i : idx} [Decidable (dom c i)] (h : dom c i):
245248
(some c[i] = c[i]?) ↔ True := by

src/Init/Grind/Config.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@ structure Config where
202202
```
203203
-/
204204
funCC := true
205+
/--
206+
When `true`, use reducible transparency when trying to close goals.
207+
In this setting, only declarations marked with `@[reducible]` are unfolded during
208+
definitional equality tests.
209+
210+
This option does not affect the canonicalizer or how theorem patterns are internalized;
211+
reducible declarations are always unfolded in those contexts.
212+
-/
213+
reducible := true
205214
deriving Inhabited, BEq
206215

207216
/--

src/Init/Grind/Util.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,15 @@ See comment at `alreadyNorm`
122122
theorem em (p : Prop) : alreadyNorm p ∨ alreadyNorm (¬ p) :=
123123
Classical.em p
124124

125+
/--
126+
Marker for grind-solved subproofs in `exact? +grind` suggestions.
127+
When `exact?` uses grind as a discharger, it wraps the proof in this marker
128+
so that the unexpander can replace it with `(by grind)` in the suggestion.
129+
-/
130+
@[inline] def Marker {α : Sort u} (a : α) : α := a
131+
132+
@[app_unexpander Marker]
133+
meta def markerUnexpander : PrettyPrinter.Unexpander := fun _ => do
134+
`(by grind)
135+
125136
end Lean.Grind

src/Init/Prelude.lean

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,8 @@ def Nat.ble : @& Nat → @& Nat → Bool
18371837
| succ _, zero => false
18381838
| succ n, succ m => ble n m
18391839

1840+
attribute [gen_constructor_elims] Bool
1841+
18401842
/--
18411843
Non-strict, or weak, inequality of natural numbers, usually accessed via the `≤` operator.
18421844
-/
@@ -1860,9 +1862,14 @@ protected def Nat.lt (n m : Nat) : Prop :=
18601862
instance instLTNat : LT Nat where
18611863
lt := Nat.lt
18621864

1863-
theorem Nat.not_succ_le_zero : ∀ (n : Nat), LE.le (succ n) 0 → False
1864-
| 0 => nofun
1865-
| succ _ => nofun
1865+
theorem Nat.not_succ_le_zero (n : Nat) : LE.le (succ n) 0 → False :=
1866+
-- No injectivity tactic until `attribute [gen_constructor_elims] Nat`
1867+
have : ∀ m, Eq m 0 → LE.le (succ n) m → False := fun _ hm hle =>
1868+
Nat.le.casesOn (motive := fun m _ => Eq m 0 → False) hle
1869+
(fun h => Nat.noConfusion h)
1870+
(fun _ h => Nat.noConfusion h)
1871+
hm
1872+
this 0 rfl
18661873

18671874
theorem Nat.not_lt_zero (n : Nat) : Not (LT.lt n 0) :=
18681875
not_succ_le_zero n
@@ -1999,10 +2006,12 @@ protected theorem Nat.lt_of_not_le {a b : Nat} (h : Not (LE.le a b)) : LT.lt b a
19992006

20002007
protected theorem Nat.add_pos_right :
20012008
{b : Nat} → (a : Nat) → (hb : LT.lt 0 b) → LT.lt 0 (HAdd.hAdd a b)
2009+
| zero, _, h => (Nat.not_succ_le_zero _ h).elim
20022010
| succ _, _, _ => Nat.zero_lt_succ _
20032011

20042012
protected theorem Nat.mul_pos :
20052013
{n m : Nat} → (hn : LT.lt 0 n) → (hm : LT.lt 0 m) → LT.lt 0 (HMul.hMul n m)
2014+
| _, zero, _, hb => (Nat.not_succ_le_zero _ hb).elim
20062015
| _, succ _, ha, _ => Nat.add_pos_right _ ha
20072016

20082017
protected theorem Nat.pow_pos {a : Nat} : {n : Nat} → (h : LT.lt 0 a) → LT.lt 0 (HPow.hPow a n)
@@ -2059,6 +2068,8 @@ protected def Nat.sub : (@& Nat) → (@& Nat) → Nat
20592068
| a, 0 => a
20602069
| a, succ b => pred (Nat.sub a b)
20612070

2071+
attribute [gen_constructor_elims] Nat
2072+
20622073
instance instSubNat : Sub Nat where
20632074
sub := Nat.sub
20642075

@@ -2216,9 +2227,6 @@ theorem Nat.mod_lt : (x : Nat) → {y : Nat} → (hy : LT.lt 0 y) → LT.lt (HM
22162227
| .isTrue _ => Nat.modCore_lt hm
22172228
| .isFalse h => Nat.lt_of_not_le h
22182229

2219-
attribute [gen_constructor_elims] Nat
2220-
attribute [gen_constructor_elims] Bool
2221-
22222230
/--
22232231
Gets the word size of the current platform. The word size may be 64 or 32 bits.
22242232

0 commit comments

Comments
 (0)