text
stringlengths 0
3.34M
|
---|
[STATEMENT]
lemma nonzero_of_rat_divide: "b \<noteq> 0 \<Longrightarrow> of_rat (a / b) = of_rat a / of_rat b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. b \<noteq> 0 \<Longrightarrow> of_rat (a / b) = of_rat a / of_rat b
[PROOF STEP]
by (simp add: divide_inverse of_rat_mult nonzero_of_rat_inverse) |
/-
Copyright (c) 2019 Tim Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Tim Baanen, Lu-Ming Zhang
-/
import algebra.regular.smul
import linear_algebra.matrix.adjugate
import linear_algebra.matrix.polynomial
/-!
# Nonsingular inverses
In this file, we define an inverse for square matrices of invertible determinant.
For matrices that are not square or not of full rank, there is a more general notion of
pseudoinverses which we do not consider here.
The definition of inverse used in this file is the adjugate divided by the determinant.
We show that dividing the adjugate by `det A` (if possible), giving a matrix `A⁻¹` (`nonsing_inv`),
will result in a multiplicative inverse to `A`.
Note that there are at least three different inverses in mathlib:
* `A⁻¹` (`has_inv.inv`): alone, this satisfies no properties, although it is usually used in
conjunction with `group` or `group_with_zero`. On matrices, this is defined to be zero when no
inverse exists.
* `⅟A` (`inv_of`): this is only available in the presence of `[invertible A]`, which guarantees an
inverse exists.
* `ring.inverse A`: this is defined on any `monoid_with_zero`, and just like `⁻¹` on matrices, is
defined to be zero when no inverse exists.
We start by working with `invertible`, and show the main results:
* `matrix.invertible_of_det_invertible`
* `matrix.det_invertible_of_invertible`
* `matrix.is_unit_iff_is_unit_det`
* `matrix.mul_eq_one_comm`
After this we define `matrix.has_inv` and show it matches `⅟A` and `ring.inverse A`.
The rest of the results in the file are then about `A⁻¹`
## References
* https://en.wikipedia.org/wiki/Cramer's_rule#Finding_inverse_matrix
## Tags
matrix inverse, cramer, cramer's rule, adjugate
-/
namespace matrix
universes u v
variables {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α]
open_locale matrix big_operators
open equiv equiv.perm finset
variables (A : matrix n n α) (B : matrix n n α)
/-! ### Matrices are `invertible` iff their determinants are -/
section invertible
/-- A copy of `inv_of_mul_self` using `⬝` not `*`. -/
protected lemma inv_of_mul_self [invertible A] : ⅟A ⬝ A = 1 := inv_of_mul_self A
/-- A copy of `mul_inv_of_self` using `⬝` not `*`. -/
protected lemma mul_inv_of_self [invertible A] : A ⬝ ⅟A = 1 := mul_inv_of_self A
/-- If `A.det` has a constructive inverse, produce one for `A`. -/
def invertible_of_det_invertible [invertible A.det] : invertible A :=
{ inv_of := ⅟A.det • A.adjugate,
mul_inv_of_self :=
by rw [mul_smul_comm, matrix.mul_eq_mul, mul_adjugate, smul_smul, inv_of_mul_self, one_smul],
inv_of_mul_self :=
by rw [smul_mul_assoc, matrix.mul_eq_mul, adjugate_mul, smul_smul, inv_of_mul_self, one_smul] }
lemma inv_of_eq [invertible A.det] [invertible A] : ⅟A = ⅟A.det • A.adjugate :=
by { letI := invertible_of_det_invertible A, convert (rfl : ⅟A = _) }
/-- `A.det` is invertible if `A` has a left inverse. -/
def det_invertible_of_left_inverse (h : B ⬝ A = 1) : invertible A.det :=
{ inv_of := B.det,
mul_inv_of_self := by rw [mul_comm, ← det_mul, h, det_one],
inv_of_mul_self := by rw [← det_mul, h, det_one] }
/-- `A.det` is invertible if `A` has a right inverse. -/
def det_invertible_of_right_inverse (h : A ⬝ B = 1) : invertible A.det :=
{ inv_of := B.det,
mul_inv_of_self := by rw [← det_mul, h, det_one],
inv_of_mul_self := by rw [mul_comm, ← det_mul, h, det_one] }
/-- If `A` has a constructive inverse, produce one for `A.det`. -/
def det_invertible_of_invertible [invertible A] : invertible A.det :=
det_invertible_of_left_inverse A (⅟A) (inv_of_mul_self _)
lemma det_inv_of [invertible A] [invertible A.det] : (⅟A).det = ⅟A.det :=
by { letI := det_invertible_of_invertible A, convert (rfl : _ = ⅟A.det) }
/-- Together `matrix.det_invertible_of_invertible` and `matrix.invertible_of_det_invertible` form an
equivalence, although both sides of the equiv are subsingleton anyway. -/
@[simps]
def invertible_equiv_det_invertible : invertible A ≃ invertible A.det :=
{ to_fun := @det_invertible_of_invertible _ _ _ _ _ A,
inv_fun := @invertible_of_det_invertible _ _ _ _ _ A,
left_inv := λ _, subsingleton.elim _ _,
right_inv := λ _, subsingleton.elim _ _ }
variables {A B}
lemma mul_eq_one_comm : A ⬝ B = 1 ↔ B ⬝ A = 1 :=
suffices ∀ A B, A ⬝ B = 1 → B ⬝ A = 1, from ⟨this A B, this B A⟩, assume A B h,
begin
letI : invertible B.det := det_invertible_of_left_inverse _ _ h,
letI : invertible B := invertible_of_det_invertible B,
calc B ⬝ A = (B ⬝ A) ⬝ (B ⬝ ⅟B) : by rw [matrix.mul_inv_of_self, matrix.mul_one]
... = B ⬝ ((A ⬝ B) ⬝ ⅟B) : by simp only [matrix.mul_assoc]
... = B ⬝ ⅟B : by rw [h, matrix.one_mul]
... = 1 : matrix.mul_inv_of_self B,
end
variables (A B)
/-- We can construct an instance of invertible A if A has a left inverse. -/
def invertible_of_left_inverse (h : B ⬝ A = 1) : invertible A :=
⟨B, h, mul_eq_one_comm.mp h⟩
/-- We can construct an instance of invertible A if A has a right inverse. -/
def invertible_of_right_inverse (h : A ⬝ B = 1) : invertible A :=
⟨B, mul_eq_one_comm.mp h, h⟩
/-- Given a proof that `A.det` has a constructive inverse, lift `A` to `units (matrix n n α)`-/
def unit_of_det_invertible [invertible A.det] : units (matrix n n α) :=
@unit_of_invertible _ _ A (invertible_of_det_invertible A)
/-- When lowered to a prop, `matrix.invertible_equiv_det_invertible` forms an `iff`. -/
lemma is_unit_iff_is_unit_det : is_unit A ↔ is_unit A.det :=
begin
split; rintros ⟨x, hx⟩; refine @is_unit_of_invertible _ _ _ (id _),
{ haveI : invertible A := hx.rec x.invertible,
apply det_invertible_of_invertible, },
{ haveI : invertible A.det := hx.rec x.invertible,
apply invertible_of_det_invertible, },
end
/-! #### Variants of the statements above with `is_unit`-/
lemma is_unit_det_of_invertible [invertible A] : is_unit A.det :=
@is_unit_of_invertible _ _ _ (det_invertible_of_invertible A)
variables {A B}
lemma is_unit_det_of_left_inverse (h : B ⬝ A = 1) : is_unit A.det :=
@is_unit_of_invertible _ _ _ (det_invertible_of_left_inverse _ _ h)
lemma is_unit_det_of_right_inverse (h : A ⬝ B = 1) : is_unit A.det :=
@is_unit_of_invertible _ _ _ (det_invertible_of_right_inverse _ _ h)
lemma det_ne_zero_of_left_inverse [nontrivial α] (h : B ⬝ A = 1) : A.det ≠ 0 :=
(is_unit_det_of_left_inverse h).ne_zero
lemma det_ne_zero_of_right_inverse [nontrivial α] (h : A ⬝ B = 1) : A.det ≠ 0 :=
(is_unit_det_of_right_inverse h).ne_zero
end invertible
open_locale classical
lemma is_unit_det_transpose (h : is_unit A.det) : is_unit Aᵀ.det :=
by { rw det_transpose, exact h, }
/-! ### A noncomputable `has_inv` instance -/
/-- The inverse of a square matrix, when it is invertible (and zero otherwise).-/
noncomputable instance : has_inv (matrix n n α) := ⟨λ A, ring.inverse A.det • A.adjugate⟩
lemma inv_def (A : matrix n n α) : A⁻¹ = ring.inverse A.det • A.adjugate := rfl
lemma nonsing_inv_apply_not_is_unit (h : ¬ is_unit A.det) :
A⁻¹ = 0 :=
by rw [inv_def, ring.inverse_non_unit _ h, zero_smul]
lemma nonsing_inv_apply (h : is_unit A.det) :
A⁻¹ = (↑h.unit⁻¹ : α) • A.adjugate :=
by rw [inv_def, ←ring.inverse_unit h.unit, is_unit.unit_spec]
/-- The nonsingular inverse is the same as `inv_of` when `A` is invertible. -/
@[simp] lemma inv_of_eq_nonsing_inv [invertible A] : ⅟A = A⁻¹ :=
begin
letI := det_invertible_of_invertible A,
rw [inv_def, ring.inverse_invertible, inv_of_eq],
end
/-- The nonsingular inverse is the same as the general `ring.inverse`. -/
lemma nonsing_inv_eq_ring_inverse : A⁻¹ = ring.inverse A :=
begin
by_cases h_det : is_unit A.det,
{ casesI (A.is_unit_iff_is_unit_det.mpr h_det).nonempty_invertible,
rw [←inv_of_eq_nonsing_inv, ring.inverse_invertible], },
{ have h := mt A.is_unit_iff_is_unit_det.mp h_det,
rw [ring.inverse_non_unit _ h, nonsing_inv_apply_not_is_unit A h_det], },
end
lemma transpose_nonsing_inv : (A⁻¹)ᵀ = (Aᵀ)⁻¹ :=
by rw [inv_def, inv_def, transpose_smul, det_transpose, adjugate_transpose]
lemma conj_transpose_nonsing_inv [star_ring α] : (A⁻¹)ᴴ = (Aᴴ)⁻¹ :=
by rw [inv_def, inv_def, conj_transpose_smul, det_conj_transpose, adjugate_conj_transpose,
ring.inverse_star]
/-- The `nonsing_inv` of `A` is a right inverse. -/
@[simp] lemma mul_nonsing_inv (h : is_unit A.det) : A ⬝ A⁻¹ = 1 :=
begin
casesI (A.is_unit_iff_is_unit_det.mpr h).nonempty_invertible,
rw [←inv_of_eq_nonsing_inv, matrix.mul_inv_of_self],
end
/-- The `nonsing_inv` of `A` is a left inverse. -/
@[simp] lemma nonsing_inv_mul (h : is_unit A.det) : A⁻¹ ⬝ A = 1 :=
begin
casesI (A.is_unit_iff_is_unit_det.mpr h).nonempty_invertible,
rw [←inv_of_eq_nonsing_inv, matrix.inv_of_mul_self],
end
@[simp] lemma mul_inv_of_invertible [invertible A] : A ⬝ A⁻¹ = 1 :=
mul_nonsing_inv A (is_unit_det_of_invertible A)
@[simp] lemma inv_mul_of_invertible [invertible A] : A⁻¹ ⬝ A = 1 :=
nonsing_inv_mul A (is_unit_det_of_invertible A)
lemma nonsing_inv_cancel_or_zero :
(A⁻¹ ⬝ A = 1 ∧ A ⬝ A⁻¹ = 1) ∨ A⁻¹ = 0 :=
begin
by_cases h : is_unit A.det,
{ exact or.inl ⟨nonsing_inv_mul _ h, mul_nonsing_inv _ h⟩ },
{ exact or.inr (nonsing_inv_apply_not_is_unit _ h) }
end
lemma det_nonsing_inv_mul_det (h : is_unit A.det) : A⁻¹.det * A.det = 1 :=
by rw [←det_mul, A.nonsing_inv_mul h, det_one]
@[simp] lemma det_nonsing_inv : A⁻¹.det = ring.inverse A.det :=
begin
by_cases h : is_unit A.det,
{ casesI h.nonempty_invertible, letI := invertible_of_det_invertible A,
rw [ring.inverse_invertible, ←inv_of_eq_nonsing_inv, det_inv_of] },
casesI is_empty_or_nonempty n,
{ rw [det_is_empty, det_is_empty, ring.inverse_one] },
{ rw [ring.inverse_non_unit _ h, nonsing_inv_apply_not_is_unit _ h, det_zero ‹_›] },
end
lemma is_unit_nonsing_inv_det (h : is_unit A.det) : is_unit A⁻¹.det :=
is_unit_of_mul_eq_one _ _ (A.det_nonsing_inv_mul_det h)
@[simp] lemma nonsing_inv_nonsing_inv (h : is_unit A.det) : (A⁻¹)⁻¹ = A :=
calc (A⁻¹)⁻¹ = 1 ⬝ (A⁻¹)⁻¹ : by rw matrix.one_mul
... = A ⬝ A⁻¹ ⬝ (A⁻¹)⁻¹ : by rw A.mul_nonsing_inv h
... = A : by { rw [matrix.mul_assoc,
(A⁻¹).mul_nonsing_inv (A.is_unit_nonsing_inv_det h),
matrix.mul_one], }
lemma is_unit_nonsing_inv_det_iff {A : matrix n n α} :
is_unit A⁻¹.det ↔ is_unit A.det :=
by rw [matrix.det_nonsing_inv, is_unit_ring_inverse]
/- `is_unit.invertible` lifts the proposition `is_unit A` to a constructive inverse of `A`. -/
/-- A version of `matrix.invertible_of_det_invertible` with the inverse defeq to `A⁻¹` that is
therefore noncomputable. -/
noncomputable def invertible_of_is_unit_det (h : is_unit A.det) : invertible A :=
⟨A⁻¹, nonsing_inv_mul A h, mul_nonsing_inv A h⟩
/-- A version of `matrix.units_of_det_invertible` with the inverse defeq to `A⁻¹` that is therefore
noncomputable. -/
noncomputable def nonsing_inv_unit (h : is_unit A.det) : units (matrix n n α) :=
@unit_of_invertible _ _ _ (invertible_of_is_unit_det A h)
lemma unit_of_det_invertible_eq_nonsing_inv_unit [invertible A.det] :
unit_of_det_invertible A = nonsing_inv_unit A (is_unit_of_invertible _) :=
by { ext, refl }
variables {A} {B}
/-- If matrix A is left invertible, then its inverse equals its left inverse. -/
lemma inv_eq_left_inv (h : B ⬝ A = 1) : A⁻¹ = B :=
begin
letI := invertible_of_left_inverse _ _ h,
exact inv_of_eq_nonsing_inv A ▸ inv_of_eq_left_inv h,
end
/-- If matrix A is right invertible, then its inverse equals its right inverse. -/
lemma inv_eq_right_inv (h : A ⬝ B = 1) : A⁻¹ = B :=
inv_eq_left_inv (mul_eq_one_comm.2 h)
section inv_eq_inv
variables {C : matrix n n α}
/-- The left inverse of matrix A is unique when existing. -/
/-- The right inverse of matrix A is unique when existing. -/
lemma right_inv_eq_right_inv (h : A ⬝ B = 1) (g : A ⬝ C = 1) : B = C :=
by rw [←inv_eq_right_inv h, ←inv_eq_right_inv g]
/-- The right inverse of matrix A equals the left inverse of A when they exist. -/
lemma right_inv_eq_left_inv (h : A ⬝ B = 1) (g : C ⬝ A = 1) : B = C :=
by rw [←inv_eq_right_inv h, ←inv_eq_left_inv g]
lemma inv_inj (h : A⁻¹ = B⁻¹) (h' : is_unit A.det) : A = B :=
begin
refine left_inv_eq_left_inv (mul_nonsing_inv _ h') _,
rw h,
refine mul_nonsing_inv _ _,
rwa [←is_unit_nonsing_inv_det_iff, ←h, is_unit_nonsing_inv_det_iff]
end
end inv_eq_inv
variable (A)
@[simp] lemma inv_zero : (0 : matrix n n α)⁻¹ = 0 :=
begin
casesI (subsingleton_or_nontrivial α) with ht ht,
{ simp },
cases (fintype.card n).zero_le.eq_or_lt with hc hc,
{ rw [eq_comm, fintype.card_eq_zero_iff] at hc,
haveI := hc,
ext i,
exact (is_empty.false i).elim },
{ have hn : nonempty n := fintype.card_pos_iff.mp hc,
refine nonsing_inv_apply_not_is_unit _ _,
simp [hn] },
end
@[simp] lemma inv_one : (1 : matrix n n α)⁻¹ = 1 :=
inv_eq_left_inv (by simp)
lemma inv_smul (k : α) [invertible k] (h : is_unit A.det) : (k • A)⁻¹ = ⅟k • A⁻¹ :=
inv_eq_left_inv (by simp [h, smul_smul])
lemma inv_smul' (k : units α) (h : is_unit A.det) : (k • A)⁻¹ = k⁻¹ • A⁻¹ :=
inv_eq_left_inv (by simp [h, smul_smul])
lemma inv_adjugate (A : matrix n n α) (h : is_unit A.det) :
(adjugate A)⁻¹ = h.unit⁻¹ • A :=
begin
refine inv_eq_left_inv _,
rw [smul_mul, mul_adjugate, units.smul_def, smul_smul, h.coe_inv_mul, one_smul]
end
@[simp] lemma inv_inv_inv (A : matrix n n α) : A⁻¹⁻¹⁻¹ = A⁻¹ :=
begin
by_cases h : is_unit A.det,
{ rw [nonsing_inv_nonsing_inv _ h] },
{ simp [nonsing_inv_apply_not_is_unit _ h] }
end
lemma mul_inv_rev (A B : matrix n n α) : (A ⬝ B)⁻¹ = B⁻¹ ⬝ A⁻¹ :=
begin
simp only [inv_def],
rw [matrix.smul_mul, matrix.mul_smul, smul_smul, det_mul, adjugate_mul_distrib,
ring.mul_inverse_rev],
end
/-- One form of **Cramer's rule**. See `matrix.mul_vec_cramer` for a stronger form. -/
@[simp] lemma det_smul_inv_mul_vec_eq_cramer (A : matrix n n α) (b : n → α) (h : is_unit A.det) :
A.det • A⁻¹.mul_vec b = cramer A b :=
begin
rw [cramer_eq_adjugate_mul_vec, A.nonsing_inv_apply h, ← smul_mul_vec_assoc,
smul_smul, h.mul_coe_inv, one_smul]
end
/-- One form of **Cramer's rule**. See `matrix.mul_vec_cramer` for a stronger form. -/
@[simp] lemma det_smul_inv_vec_mul_eq_cramer_transpose
(A : matrix n n α) (b : n → α) (h : is_unit A.det) :
A.det • A⁻¹.vec_mul b = cramer Aᵀ b :=
by rw [← (A⁻¹).transpose_transpose, vec_mul_transpose, transpose_nonsing_inv, ← det_transpose,
Aᵀ.det_smul_inv_mul_vec_eq_cramer _ (is_unit_det_transpose A h)]
end matrix
|
State Before: R : Type u
S : Type v
a✝ b c d : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q : R[X]
ι : Type ?u.562120
p : R[X]
n : ℕ
a : R
⊢ degree (update p n a) ≤ max (degree p) ↑n State After: R : Type u
S : Type v
a✝ b c d : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q : R[X]
ι : Type ?u.562120
p : R[X]
n : ℕ
a : R
⊢ Finset.max (if a = 0 then Finset.erase (support p) n else insert n (support p)) ≤ max (degree p) ↑n Tactic: rw [degree, support_update] State Before: R : Type u
S : Type v
a✝ b c d : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q : R[X]
ι : Type ?u.562120
p : R[X]
n : ℕ
a : R
⊢ Finset.max (if a = 0 then Finset.erase (support p) n else insert n (support p)) ≤ max (degree p) ↑n State After: case inl
R : Type u
S : Type v
a✝ b c d : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q : R[X]
ι : Type ?u.562120
p : R[X]
n : ℕ
a : R
h✝ : a = 0
⊢ Finset.max (Finset.erase (support p) n) ≤ max (degree p) ↑n
case inr
R : Type u
S : Type v
a✝ b c d : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q : R[X]
ι : Type ?u.562120
p : R[X]
n : ℕ
a : R
h✝ : ¬a = 0
⊢ Finset.max (insert n (support p)) ≤ max (degree p) ↑n Tactic: split_ifs State Before: case inl
R : Type u
S : Type v
a✝ b c d : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q : R[X]
ι : Type ?u.562120
p : R[X]
n : ℕ
a : R
h✝ : a = 0
⊢ Finset.max (Finset.erase (support p) n) ≤ max (degree p) ↑n State After: no goals Tactic: exact (Finset.max_mono (erase_subset _ _)).trans (le_max_left _ _) State Before: case inr
R : Type u
S : Type v
a✝ b c d : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q : R[X]
ι : Type ?u.562120
p : R[X]
n : ℕ
a : R
h✝ : ¬a = 0
⊢ Finset.max (insert n (support p)) ≤ max (degree p) ↑n State After: case inr
R : Type u
S : Type v
a✝ b c d : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q : R[X]
ι : Type ?u.562120
p : R[X]
n : ℕ
a : R
h✝ : ¬a = 0
⊢ max (Finset.max (support p)) ↑n ≤ max (degree p) ↑n Tactic: rw [max_insert, max_comm] State Before: case inr
R : Type u
S : Type v
a✝ b c d : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q : R[X]
ι : Type ?u.562120
p : R[X]
n : ℕ
a : R
h✝ : ¬a = 0
⊢ max (Finset.max (support p)) ↑n ≤ max (degree p) ↑n State After: no goals Tactic: exact le_rfl |
From Test Require Import tactic.
Section FOFProblem.
Variable Universe : Set.
Variable UniverseElement : Universe.
Variable r_ : Prop.
Variable q_ : Prop.
Variable p_ : Prop.
Variable goal_ : Prop.
Variable assump_1 : (True -> (p_ \/ (q_ \/ r_))).
Variable goal_p_2 : (p_ -> goal_).
Variable goal_q_3 : (q_ -> goal_).
Variable goal_r_4 : (r_ -> goal_).
Theorem or3_5 : goal_.
Proof.
time tac.
Qed.
End FOFProblem.
|
module Highlighting where
Set-one : Set₂
Set-one = Set₁
record R (A : Set) : Set-one where
constructor con
field X : Set
F : Set → Set → Set
F A B = B
field P : F A X → Set
-- highlighting of non-terminating definition
Q : F A X → Set
Q = Q
postulate P : _
open import Highlighting.M
data D (A : Set) : Set-one where
d : let X = D in X A
postulate _+_ _×_ : Set → Set → Set
infixl 4 _×_ _+_
-- Issue #2140: the operators should be highlighted also in the
-- fixity declaration.
|
!*==csytf2_rook.f90 processed by SPAG 7.51RB at 20:08 on 3 Mar 2022
!> \brief \b CSYTF2_ROOK computes the factorization of a complex symmetric indefinite matrix using the bounded Bunch-Kaufman ("rook") diagonal pivoting method (unblocked algorithm).
!
! =========== DOCUMENTATION ===========
!
! Online html documentation available at
! http://www.netlib.org/lapack/explore-html/
!
!> \htmlonly
!> Download CSYTF2_ROOK + dependencies
!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/csytf2_rook.f">
!> [TGZ]</a>
!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/csytf2_rook.f">
!> [ZIP]</a>
!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/csytf2_rook.f">
!> [TXT]</a>
!> \endhtmlonly
!
! Definition:
! ===========
!
! SUBROUTINE CSYTF2_ROOK( UPLO, N, A, LDA, IPIV, INFO )
!
! .. Scalar Arguments ..
! CHARACTER UPLO
! INTEGER INFO, LDA, N
! ..
! .. Array Arguments ..
! INTEGER IPIV( * )
! COMPLEX A( LDA, * )
! ..
!
!
!> \par Purpose:
! =============
!>
!> \verbatim
!>
!> CSYTF2_ROOK computes the factorization of a complex symmetric matrix A
!> using the bounded Bunch-Kaufman ("rook") diagonal pivoting method:
!>
!> A = U*D*U**T or A = L*D*L**T
!>
!> where U (or L) is a product of permutation and unit upper (lower)
!> triangular matrices, U**T is the transpose of U, and D is symmetric and
!> block diagonal with 1-by-1 and 2-by-2 diagonal blocks.
!>
!> This is the unblocked version of the algorithm, calling Level 2 BLAS.
!> \endverbatim
!
! Arguments:
! ==========
!
!> \param[in] UPLO
!> \verbatim
!> UPLO is CHARACTER*1
!> Specifies whether the upper or lower triangular part of the
!> symmetric matrix A is stored:
!> = 'U': Upper triangular
!> = 'L': Lower triangular
!> \endverbatim
!>
!> \param[in] N
!> \verbatim
!> N is INTEGER
!> The order of the matrix A. N >= 0.
!> \endverbatim
!>
!> \param[in,out] A
!> \verbatim
!> A is COMPLEX array, dimension (LDA,N)
!> On entry, the symmetric matrix A. If UPLO = 'U', the leading
!> n-by-n upper triangular part of A contains the upper
!> triangular part of the matrix A, and the strictly lower
!> triangular part of A is not referenced. If UPLO = 'L', the
!> leading n-by-n lower triangular part of A contains the lower
!> triangular part of the matrix A, and the strictly upper
!> triangular part of A is not referenced.
!>
!> On exit, the block diagonal matrix D and the multipliers used
!> to obtain the factor U or L (see below for further details).
!> \endverbatim
!>
!> \param[in] LDA
!> \verbatim
!> LDA is INTEGER
!> The leading dimension of the array A. LDA >= max(1,N).
!> \endverbatim
!>
!> \param[out] IPIV
!> \verbatim
!> IPIV is INTEGER array, dimension (N)
!> Details of the interchanges and the block structure of D.
!>
!> If UPLO = 'U':
!> If IPIV(k) > 0, then rows and columns k and IPIV(k)
!> were interchanged and D(k,k) is a 1-by-1 diagonal block.
!>
!> If IPIV(k) < 0 and IPIV(k-1) < 0, then rows and
!> columns k and -IPIV(k) were interchanged and rows and
!> columns k-1 and -IPIV(k-1) were inerchaged,
!> D(k-1:k,k-1:k) is a 2-by-2 diagonal block.
!>
!> If UPLO = 'L':
!> If IPIV(k) > 0, then rows and columns k and IPIV(k)
!> were interchanged and D(k,k) is a 1-by-1 diagonal block.
!>
!> If IPIV(k) < 0 and IPIV(k+1) < 0, then rows and
!> columns k and -IPIV(k) were interchanged and rows and
!> columns k+1 and -IPIV(k+1) were inerchaged,
!> D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
!> \endverbatim
!>
!> \param[out] INFO
!> \verbatim
!> INFO is INTEGER
!> = 0: successful exit
!> < 0: if INFO = -k, the k-th argument had an illegal value
!> > 0: if INFO = k, D(k,k) is exactly zero. The factorization
!> has been completed, but the block diagonal matrix D is
!> exactly singular, and division by zero will occur if it
!> is used to solve a system of equations.
!> \endverbatim
!
! Authors:
! ========
!
!> \author Univ. of Tennessee
!> \author Univ. of California Berkeley
!> \author Univ. of Colorado Denver
!> \author NAG Ltd.
!
!> \date November 2013
!
!> \ingroup complexSYcomputational
!
!> \par Further Details:
! =====================
!>
!> \verbatim
!>
!> If UPLO = 'U', then A = U*D*U**T, where
!> U = P(n)*U(n)* ... *P(k)U(k)* ...,
!> i.e., U is a product of terms P(k)*U(k), where k decreases from n to
!> 1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
!> and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
!> defined by IPIV(k), and U(k) is a unit upper triangular matrix, such
!> that if the diagonal block D(k) is of order s (s = 1 or 2), then
!>
!> ( I v 0 ) k-s
!> U(k) = ( 0 I 0 ) s
!> ( 0 0 I ) n-k
!> k-s s n-k
!>
!> If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k).
!> If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k),
!> and A(k,k), and v overwrites A(1:k-2,k-1:k).
!>
!> If UPLO = 'L', then A = L*D*L**T, where
!> L = P(1)*L(1)* ... *P(k)*L(k)* ...,
!> i.e., L is a product of terms P(k)*L(k), where k increases from 1 to
!> n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
!> and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
!> defined by IPIV(k), and L(k) is a unit lower triangular matrix, such
!> that if the diagonal block D(k) is of order s (s = 1 or 2), then
!>
!> ( I 0 0 ) k-1
!> L(k) = ( 0 I 0 ) s
!> ( 0 v I ) n-k-s+1
!> k-1 s n-k-s+1
!>
!> If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).
!> If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k),
!> and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).
!> \endverbatim
!
!> \par Contributors:
! ==================
!>
!> \verbatim
!>
!> November 2013, Igor Kozachenko,
!> Computer Science Division,
!> University of California, Berkeley
!>
!> September 2007, Sven Hammarling, Nicholas J. Higham, Craig Lucas,
!> School of Mathematics,
!> University of Manchester
!>
!> 01-01-96 - Based on modifications by
!> J. Lewis, Boeing Computer Services Company
!> A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville abd , USA
!> \endverbatim
!
! =====================================================================
SUBROUTINE CSYTF2_ROOK(Uplo,N,A,Lda,Ipiv,Info)
IMPLICIT NONE
!*--CSYTF2_ROOK198
!
! -- LAPACK computational routine (version 3.5.0) --
! -- LAPACK is a software package provided by Univ. of Tennessee, --
! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
! November 2013
!
! .. Scalar Arguments ..
CHARACTER Uplo
INTEGER Info , Lda , N
! ..
! .. Array Arguments ..
INTEGER Ipiv(*)
COMPLEX A(Lda,*)
! ..
!
! =====================================================================
!
! .. Parameters ..
REAL ZERO , ONE
PARAMETER (ZERO=0.0E+0,ONE=1.0E+0)
REAL EIGHT , SEVTEN
PARAMETER (EIGHT=8.0E+0,SEVTEN=17.0E+0)
COMPLEX CONE
PARAMETER (CONE=(1.0E+0,0.0E+0))
! ..
! .. Local Scalars ..
LOGICAL upper , done
INTEGER i , imax , j , jmax , itemp , k , kk , kp , kstep , p , ii
REAL absakk , alpha , colmax , rowmax , stemp , sfmin
COMPLEX d11 , d12 , d21 , d22 , t , wk , wkm1 , wkp1 , z
! ..
! .. External Functions ..
LOGICAL LSAME
INTEGER ICAMAX
REAL SLAMCH
EXTERNAL LSAME , ICAMAX , SLAMCH
! ..
! .. External Subroutines ..
EXTERNAL CSCAL , CSWAP , CSYR , XERBLA
! ..
! .. Intrinsic Functions ..
INTRINSIC ABS , MAX , SQRT , AIMAG , REAL
! ..
! .. Statement Functions ..
REAL CABS1
! ..
! .. Statement Function definitions ..
CABS1(z) = ABS(REAL(z)) + ABS(AIMAG(z))
! ..
! .. Executable Statements ..
!
! Test the input parameters.
!
Info = 0
upper = LSAME(Uplo,'U')
IF ( .NOT.upper .AND. .NOT.LSAME(Uplo,'L') ) THEN
Info = -1
ELSEIF ( N<0 ) THEN
Info = -2
ELSEIF ( Lda<MAX(1,N) ) THEN
Info = -4
ENDIF
IF ( Info/=0 ) THEN
CALL XERBLA('CSYTF2_ROOK',-Info)
RETURN
ENDIF
!
! Initialize ALPHA for use in choosing pivot block size.
!
alpha = (ONE+SQRT(SEVTEN))/EIGHT
!
! Compute machine safe minimum
!
sfmin = SLAMCH('S')
!
IF ( upper ) THEN
!
! Factorize A as U*D*U**T using the upper triangle of A
!
! K is the main loop index, decreasing from N to 1 in steps of
! 1 or 2
!
k = N
!
! If K < 1, exit from loop
!
DO WHILE ( k>=1 )
kstep = 1
p = k
!
! Determine rows and columns to be interchanged and whether
! a 1-by-1 or 2-by-2 pivot block will be used
!
absakk = CABS1(A(k,k))
!
! IMAX is the row-index of the largest off-diagonal element in
! column K, and COLMAX is its absolute value.
! Determine both COLMAX and IMAX.
!
IF ( k>1 ) THEN
imax = ICAMAX(k-1,A(1,k),1)
colmax = CABS1(A(imax,k))
ELSE
colmax = ZERO
ENDIF
!
IF ( (MAX(absakk,colmax)==ZERO) ) THEN
!
! Column K is zero or underflow: set INFO and continue
!
IF ( Info==0 ) Info = k
kp = k
ELSE
!
! Test for interchange
!
! Equivalent to testing for (used to handle NaN and Inf)
! ABSAKK.GE.ALPHA*COLMAX
!
IF ( absakk>=alpha*colmax ) THEN
!
! no interchange,
! use 1-by-1 pivot block
!
kp = k
ELSE
!
done = .FALSE.
DO
!
! Loop until pivot found
!
!
! Begin pivot search loop body
!
! JMAX is the column-index of the largest off-diagonal
! element in row IMAX, and ROWMAX is its absolute value.
! Determine both ROWMAX and JMAX.
!
IF ( imax/=k ) THEN
jmax = imax + ICAMAX(k-imax,A(imax,imax+1),Lda)
rowmax = CABS1(A(imax,jmax))
ELSE
rowmax = ZERO
ENDIF
!
IF ( imax>1 ) THEN
itemp = ICAMAX(imax-1,A(1,imax),1)
stemp = CABS1(A(itemp,imax))
IF ( stemp>rowmax ) THEN
rowmax = stemp
jmax = itemp
ENDIF
ENDIF
!
! Equivalent to testing for (used to handle NaN and Inf)
! CABS1( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX
!
IF ( CABS1(A(imax,imax))>=alpha*rowmax ) THEN
!
! interchange rows and columns K and IMAX,
! use 1-by-1 pivot block
!
kp = imax
done = .TRUE.
!
! Equivalent to testing for ROWMAX .EQ. COLMAX,
! used to handle NaN and Inf
!
ELSEIF ( (p==jmax) .OR. (rowmax<=colmax) ) THEN
!
! interchange rows and columns K+1 and IMAX,
! use 2-by-2 pivot block
!
kp = imax
kstep = 2
done = .TRUE.
ELSE
!
! Pivot NOT found, set variables and repeat
!
p = imax
colmax = rowmax
imax = jmax
ENDIF
!
! End pivot search loop body
!
IF ( done ) EXIT
ENDDO
!
ENDIF
!
! Swap TWO rows and TWO columns
!
! First swap
!
IF ( (kstep==2) .AND. (p/=k) ) THEN
!
! Interchange rows and column K and P in the leading
! submatrix A(1:k,1:k) if we have a 2-by-2 pivot
!
IF ( p>1 ) CALL CSWAP(p-1,A(1,k),1,A(1,p),1)
IF ( p<(k-1) ) CALL CSWAP(k-p-1,A(p+1,k),1,A(p,p+1), &
& Lda)
t = A(k,k)
A(k,k) = A(p,p)
A(p,p) = t
ENDIF
!
! Second swap
!
kk = k - kstep + 1
IF ( kp/=kk ) THEN
!
! Interchange rows and columns KK and KP in the leading
! submatrix A(1:k,1:k)
!
IF ( kp>1 ) CALL CSWAP(kp-1,A(1,kk),1,A(1,kp),1)
IF ( (kk>1) .AND. (kp<(kk-1)) ) &
& CALL CSWAP(kk-kp-1,A(kp+1,kk),1,A(kp,kp+1),Lda)
t = A(kk,kk)
A(kk,kk) = A(kp,kp)
A(kp,kp) = t
IF ( kstep==2 ) THEN
t = A(k-1,k)
A(k-1,k) = A(kp,k)
A(kp,k) = t
ENDIF
ENDIF
!
! Update the leading submatrix
!
IF ( kstep==1 ) THEN
!
! 1-by-1 pivot block D(k): column k now holds
!
! W(k) = U(k)*D(k)
!
! where U(k) is the k-th column of U
!
IF ( k>1 ) THEN
!
! Perform a rank-1 update of A(1:k-1,1:k-1) and
! store U(k) in column k
!
IF ( CABS1(A(k,k))>=sfmin ) THEN
!
! Perform a rank-1 update of A(1:k-1,1:k-1) as
! A := A - U(k)*D(k)*U(k)**T
! = A - W(k)*1/D(k)*W(k)**T
!
d11 = CONE/A(k,k)
CALL CSYR(Uplo,k-1,-d11,A(1,k),1,A,Lda)
!
! Store U(k) in column k
!
CALL CSCAL(k-1,d11,A(1,k),1)
ELSE
!
! Store L(k) in column K
!
d11 = A(k,k)
DO ii = 1 , k - 1
A(ii,k) = A(ii,k)/d11
ENDDO
!
! Perform a rank-1 update of A(k+1:n,k+1:n) as
! A := A - U(k)*D(k)*U(k)**T
! = A - W(k)*(1/D(k))*W(k)**T
! = A - (W(k)/D(k))*(D(k))*(W(k)/D(K))**T
!
CALL CSYR(Uplo,k-1,-d11,A(1,k),1,A,Lda)
ENDIF
ENDIF
!
!
! 2-by-2 pivot block D(k): columns k and k-1 now hold
!
! ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k)
!
! where U(k) and U(k-1) are the k-th and (k-1)-th columns
! of U
!
! Perform a rank-2 update of A(1:k-2,1:k-2) as
!
! A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**T
! = A - ( ( A(k-1)A(k) )*inv(D(k)) ) * ( A(k-1)A(k) )**T
!
! and store L(k) and L(k+1) in columns k and k+1
!
ELSEIF ( k>2 ) THEN
!
d12 = A(k-1,k)
d22 = A(k-1,k-1)/d12
d11 = A(k,k)/d12
t = CONE/(d11*d22-CONE)
!
DO j = k - 2 , 1 , -1
!
wkm1 = t*(d11*A(j,k-1)-A(j,k))
wk = t*(d22*A(j,k)-A(j,k-1))
!
DO i = j , 1 , -1
A(i,j) = A(i,j) - (A(i,k)/d12) &
& *wk - (A(i,k-1)/d12)*wkm1
ENDDO
!
! Store U(k) and U(k-1) in cols k and k-1 for row J
!
A(j,k) = wk/d12
A(j,k-1) = wkm1/d12
!
ENDDO
!
!
ENDIF
ENDIF
!
! Store details of the interchanges in IPIV
!
IF ( kstep==1 ) THEN
Ipiv(k) = kp
ELSE
Ipiv(k) = -p
Ipiv(k-1) = -kp
ENDIF
!
! Decrease K and return to the start of the main loop
!
k = k - kstep
ENDDO
!
ELSE
!
! Factorize A as L*D*L**T using the lower triangle of A
!
! K is the main loop index, increasing from 1 to N in steps of
! 1 or 2
!
k = 1
!
! If K > N, exit from loop
!
DO WHILE ( k<=N )
kstep = 1
p = k
!
! Determine rows and columns to be interchanged and whether
! a 1-by-1 or 2-by-2 pivot block will be used
!
absakk = CABS1(A(k,k))
!
! IMAX is the row-index of the largest off-diagonal element in
! column K, and COLMAX is its absolute value.
! Determine both COLMAX and IMAX.
!
IF ( k<N ) THEN
imax = k + ICAMAX(N-k,A(k+1,k),1)
colmax = CABS1(A(imax,k))
ELSE
colmax = ZERO
ENDIF
!
IF ( (MAX(absakk,colmax)==ZERO) ) THEN
!
! Column K is zero or underflow: set INFO and continue
!
IF ( Info==0 ) Info = k
kp = k
ELSE
!
! Test for interchange
!
! Equivalent to testing for (used to handle NaN and Inf)
! ABSAKK.GE.ALPHA*COLMAX
!
IF ( absakk>=alpha*colmax ) THEN
!
! no interchange, use 1-by-1 pivot block
!
kp = k
ELSE
!
done = .FALSE.
DO
!
! Loop until pivot found
!
!
! Begin pivot search loop body
!
! JMAX is the column-index of the largest off-diagonal
! element in row IMAX, and ROWMAX is its absolute value.
! Determine both ROWMAX and JMAX.
!
IF ( imax/=k ) THEN
jmax = k - 1 + ICAMAX(imax-k,A(imax,k),Lda)
rowmax = CABS1(A(imax,jmax))
ELSE
rowmax = ZERO
ENDIF
!
IF ( imax<N ) THEN
itemp = imax + ICAMAX(N-imax,A(imax+1,imax),1)
stemp = CABS1(A(itemp,imax))
IF ( stemp>rowmax ) THEN
rowmax = stemp
jmax = itemp
ENDIF
ENDIF
!
! Equivalent to testing for (used to handle NaN and Inf)
! CABS1( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX
!
IF ( CABS1(A(imax,imax))>=alpha*rowmax ) THEN
!
! interchange rows and columns K and IMAX,
! use 1-by-1 pivot block
!
kp = imax
done = .TRUE.
!
! Equivalent to testing for ROWMAX .EQ. COLMAX,
! used to handle NaN and Inf
!
ELSEIF ( (p==jmax) .OR. (rowmax<=colmax) ) THEN
!
! interchange rows and columns K+1 and IMAX,
! use 2-by-2 pivot block
!
kp = imax
kstep = 2
done = .TRUE.
ELSE
!
! Pivot NOT found, set variables and repeat
!
p = imax
colmax = rowmax
imax = jmax
ENDIF
!
! End pivot search loop body
!
IF ( done ) EXIT
ENDDO
!
ENDIF
!
! Swap TWO rows and TWO columns
!
! First swap
!
IF ( (kstep==2) .AND. (p/=k) ) THEN
!
! Interchange rows and column K and P in the trailing
! submatrix A(k:n,k:n) if we have a 2-by-2 pivot
!
IF ( p<N ) CALL CSWAP(N-p,A(p+1,k),1,A(p+1,p),1)
IF ( p>(k+1) ) CALL CSWAP(p-k-1,A(k+1,k),1,A(p,k+1), &
& Lda)
t = A(k,k)
A(k,k) = A(p,p)
A(p,p) = t
ENDIF
!
! Second swap
!
kk = k + kstep - 1
IF ( kp/=kk ) THEN
!
! Interchange rows and columns KK and KP in the trailing
! submatrix A(k:n,k:n)
!
IF ( kp<N ) CALL CSWAP(N-kp,A(kp+1,kk),1,A(kp+1,kp),1)
IF ( (kk<N) .AND. (kp>(kk+1)) ) &
& CALL CSWAP(kp-kk-1,A(kk+1,kk),1,A(kp,kk+1),Lda)
t = A(kk,kk)
A(kk,kk) = A(kp,kp)
A(kp,kp) = t
IF ( kstep==2 ) THEN
t = A(k+1,k)
A(k+1,k) = A(kp,k)
A(kp,k) = t
ENDIF
ENDIF
!
! Update the trailing submatrix
!
IF ( kstep==1 ) THEN
!
! 1-by-1 pivot block D(k): column k now holds
!
! W(k) = L(k)*D(k)
!
! where L(k) is the k-th column of L
!
IF ( k<N ) THEN
!
! Perform a rank-1 update of A(k+1:n,k+1:n) and
! store L(k) in column k
!
IF ( CABS1(A(k,k))>=sfmin ) THEN
!
! Perform a rank-1 update of A(k+1:n,k+1:n) as
! A := A - L(k)*D(k)*L(k)**T
! = A - W(k)*(1/D(k))*W(k)**T
!
d11 = CONE/A(k,k)
CALL CSYR(Uplo,N-k,-d11,A(k+1,k),1,A(k+1,k+1), &
& Lda)
!
! Store L(k) in column k
!
CALL CSCAL(N-k,d11,A(k+1,k),1)
ELSE
!
! Store L(k) in column k
!
d11 = A(k,k)
DO ii = k + 1 , N
A(ii,k) = A(ii,k)/d11
ENDDO
!
! Perform a rank-1 update of A(k+1:n,k+1:n) as
! A := A - L(k)*D(k)*L(k)**T
! = A - W(k)*(1/D(k))*W(k)**T
! = A - (W(k)/D(k))*(D(k))*(W(k)/D(K))**T
!
CALL CSYR(Uplo,N-k,-d11,A(k+1,k),1,A(k+1,k+1), &
& Lda)
ENDIF
ENDIF
!
!
! 2-by-2 pivot block D(k): columns k and k+1 now hold
!
! ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k)
!
! where L(k) and L(k+1) are the k-th and (k+1)-th columns
! of L
!
!
! Perform a rank-2 update of A(k+2:n,k+2:n) as
!
! A := A - ( L(k) L(k+1) ) * D(k) * ( L(k) L(k+1) )**T
! = A - ( ( A(k)A(k+1) )*inv(D(k) ) * ( A(k)A(k+1) )**T
!
! and store L(k) and L(k+1) in columns k and k+1
!
ELSEIF ( k<N-1 ) THEN
!
d21 = A(k+1,k)
d11 = A(k+1,k+1)/d21
d22 = A(k,k)/d21
t = CONE/(d11*d22-CONE)
!
DO j = k + 2 , N
!
! Compute D21 * ( W(k)W(k+1) ) * inv(D(k)) for row J
!
wk = t*(d11*A(j,k)-A(j,k+1))
wkp1 = t*(d22*A(j,k+1)-A(j,k))
!
! Perform a rank-2 update of A(k+2:n,k+2:n)
!
DO i = j , N
A(i,j) = A(i,j) - (A(i,k)/d21) &
& *wk - (A(i,k+1)/d21)*wkp1
ENDDO
!
! Store L(k) and L(k+1) in cols k and k+1 for row J
!
A(j,k) = wk/d21
A(j,k+1) = wkp1/d21
!
ENDDO
!
!
ENDIF
ENDIF
!
! Store details of the interchanges in IPIV
!
IF ( kstep==1 ) THEN
Ipiv(k) = kp
ELSE
Ipiv(k) = -p
Ipiv(k+1) = -kp
ENDIF
!
! Increase K and return to the start of the main loop
!
k = k + kstep
ENDDO
!
ENDIF
!
!
!
! End of CSYTF2_ROOK
!
END SUBROUTINE CSYTF2_ROOK
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.CommRing where
open import Cubical.Algebra.CommRing.Base public
|
State Before: 𝕜 : Type u_2
E : Type u_1
F : Type u_3
G : Type u_4
inst✝⁶ : NontriviallyNormedField 𝕜
inst✝⁵ : NormedAddCommGroup E
inst✝⁴ : NormedSpace 𝕜 E
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedAddCommGroup G
inst✝ : NormedSpace 𝕜 G
f g✝ : E → F
p pf pg : FormalMultilinearSeries 𝕜 E F
x : E
r r' : ℝ≥0∞
s : Set E
g : F →L[𝕜] G
h : AnalyticOn 𝕜 f s
⊢ AnalyticOn 𝕜 (↑g ∘ f) s State After: 𝕜 : Type u_2
E : Type u_1
F : Type u_3
G : Type u_4
inst✝⁶ : NontriviallyNormedField 𝕜
inst✝⁵ : NormedAddCommGroup E
inst✝⁴ : NormedSpace 𝕜 E
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedAddCommGroup G
inst✝ : NormedSpace 𝕜 G
f g✝ : E → F
p pf pg : FormalMultilinearSeries 𝕜 E F
x✝ : E
r r' : ℝ≥0∞
s : Set E
g : F →L[𝕜] G
h : AnalyticOn 𝕜 f s
x : E
hx : x ∈ s
⊢ AnalyticAt 𝕜 (↑g ∘ f) x Tactic: rintro x hx State Before: 𝕜 : Type u_2
E : Type u_1
F : Type u_3
G : Type u_4
inst✝⁶ : NontriviallyNormedField 𝕜
inst✝⁵ : NormedAddCommGroup E
inst✝⁴ : NormedSpace 𝕜 E
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedAddCommGroup G
inst✝ : NormedSpace 𝕜 G
f g✝ : E → F
p pf pg : FormalMultilinearSeries 𝕜 E F
x✝ : E
r r' : ℝ≥0∞
s : Set E
g : F →L[𝕜] G
h : AnalyticOn 𝕜 f s
x : E
hx : x ∈ s
⊢ AnalyticAt 𝕜 (↑g ∘ f) x State After: case intro.intro
𝕜 : Type u_2
E : Type u_1
F : Type u_3
G : Type u_4
inst✝⁶ : NontriviallyNormedField 𝕜
inst✝⁵ : NormedAddCommGroup E
inst✝⁴ : NormedSpace 𝕜 E
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedAddCommGroup G
inst✝ : NormedSpace 𝕜 G
f g✝ : E → F
p✝ pf pg : FormalMultilinearSeries 𝕜 E F
x✝ : E
r✝ r' : ℝ≥0∞
s : Set E
g : F →L[𝕜] G
h : AnalyticOn 𝕜 f s
x : E
hx : x ∈ s
p : FormalMultilinearSeries 𝕜 E F
r : ℝ≥0∞
hp : HasFPowerSeriesOnBall f p x r
⊢ AnalyticAt 𝕜 (↑g ∘ f) x Tactic: rcases h x hx with ⟨p, r, hp⟩ State Before: case intro.intro
𝕜 : Type u_2
E : Type u_1
F : Type u_3
G : Type u_4
inst✝⁶ : NontriviallyNormedField 𝕜
inst✝⁵ : NormedAddCommGroup E
inst✝⁴ : NormedSpace 𝕜 E
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace 𝕜 F
inst✝¹ : NormedAddCommGroup G
inst✝ : NormedSpace 𝕜 G
f g✝ : E → F
p✝ pf pg : FormalMultilinearSeries 𝕜 E F
x✝ : E
r✝ r' : ℝ≥0∞
s : Set E
g : F →L[𝕜] G
h : AnalyticOn 𝕜 f s
x : E
hx : x ∈ s
p : FormalMultilinearSeries 𝕜 E F
r : ℝ≥0∞
hp : HasFPowerSeriesOnBall f p x r
⊢ AnalyticAt 𝕜 (↑g ∘ f) x State After: no goals Tactic: exact ⟨g.compFormalMultilinearSeries p, r, g.comp_hasFPowerSeriesOnBall hp⟩ |
Formal statement is: lemma integral_restrict: fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space" assumes "S \<subseteq> T" "S \<in> sets lebesgue" "T \<in> sets lebesgue" shows "integral\<^sup>L (lebesgue_on T) (\<lambda>x. if x \<in> S then f x else 0) = integral\<^sup>L (lebesgue_on S) f" Informal statement is: If $S$ is a subset of $T$ and both $S$ and $T$ are Lebesgue measurable, then the integral of $f$ over $S$ is equal to the integral of $f$ over $T$ restricted to $S$. |
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
ifp_n : IntFractPair K
stream_nth_eq : IntFractPair.stream v n = some ifp_n
nth_fr_eq_zero : ifp_n.fr = 0
⊢ IntFractPair.stream v (n + 1) = none
[PROOFSTEP]
cases' ifp_n with _ fr
[GOAL]
case mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
b✝ : ℤ
fr : K
stream_nth_eq : IntFractPair.stream v n = some { b := b✝, fr := fr }
nth_fr_eq_zero : { b := b✝, fr := fr }.fr = 0
⊢ IntFractPair.stream v (n + 1) = none
[PROOFSTEP]
change fr = 0 at nth_fr_eq_zero
[GOAL]
case mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
b✝ : ℤ
fr : K
stream_nth_eq : IntFractPair.stream v n = some { b := b✝, fr := fr }
nth_fr_eq_zero : fr = 0
⊢ IntFractPair.stream v (n + 1) = none
[PROOFSTEP]
simp [IntFractPair.stream, stream_nth_eq, nth_fr_eq_zero]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
⊢ IntFractPair.stream v (n + 1) = none ↔
IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0
[PROOFSTEP]
rw [IntFractPair.stream]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
⊢ (Option.bind (IntFractPair.stream v n) fun ap_n => if ap_n.fr = 0 then none else some (IntFractPair.of ap_n.fr⁻¹)) =
none ↔
IntFractPair.stream v n = none ∨ ∃ ifp, IntFractPair.stream v n = some ifp ∧ ifp.fr = 0
[PROOFSTEP]
cases IntFractPair.stream v n
[GOAL]
case none
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
⊢ (Option.bind none fun ap_n => if ap_n.fr = 0 then none else some (IntFractPair.of ap_n.fr⁻¹)) = none ↔
none = none ∨ ∃ ifp, none = some ifp ∧ ifp.fr = 0
[PROOFSTEP]
simp [imp_false]
[GOAL]
case some
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
val✝ : IntFractPair K
⊢ (Option.bind (some val✝) fun ap_n => if ap_n.fr = 0 then none else some (IntFractPair.of ap_n.fr⁻¹)) = none ↔
some val✝ = none ∨ ∃ ifp, some val✝ = some ifp ∧ ifp.fr = 0
[PROOFSTEP]
simp [imp_false]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
ifp_succ_n : IntFractPair K
⊢ IntFractPair.stream v (n + 1) = some ifp_succ_n ↔
∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr ≠ 0 ∧ IntFractPair.of ifp_n.fr⁻¹ = ifp_succ_n
[PROOFSTEP]
simp [IntFractPair.stream, ite_eq_iff]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
a : ℤ
n : ℕ
⊢ IntFractPair.stream (↑a) (n + 1) = none
[PROOFSTEP]
induction' n with n ih
[GOAL]
case zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
a : ℤ
⊢ IntFractPair.stream (↑a) (Nat.zero + 1) = none
[PROOFSTEP]
refine' IntFractPair.stream_eq_none_of_fr_eq_zero (IntFractPair.stream_zero (a : K)) _
[GOAL]
case zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
a : ℤ
⊢ (IntFractPair.of ↑a).fr = 0
[PROOFSTEP]
simp only [IntFractPair.of, Int.fract_intCast]
[GOAL]
case succ
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
a : ℤ
n : ℕ
ih : IntFractPair.stream (↑a) (n + 1) = none
⊢ IntFractPair.stream (↑a) (Nat.succ n + 1) = none
[PROOFSTEP]
exact IntFractPair.succ_nth_stream_eq_none_iff.mpr (Or.inl ih)
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
ifp_succ_n : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n
succ_nth_fr_eq_zero : ifp_succ_n.fr = 0
⊢ ∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr⁻¹ = ↑⌊ifp_n.fr⁻¹⌋
[PROOFSTEP]
rcases succ_nth_stream_eq_some_iff.mp stream_succ_nth_eq with ⟨ifp_n, seq_nth_eq, _, rfl⟩
[GOAL]
case intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
ifp_n : IntFractPair K
seq_nth_eq : IntFractPair.stream v n = some ifp_n
left✝ : ifp_n.fr ≠ 0
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some (IntFractPair.of ifp_n.fr⁻¹)
succ_nth_fr_eq_zero : (IntFractPair.of ifp_n.fr⁻¹).fr = 0
⊢ ∃ ifp_n, IntFractPair.stream v n = some ifp_n ∧ ifp_n.fr⁻¹ = ↑⌊ifp_n.fr⁻¹⌋
[PROOFSTEP]
refine' ⟨ifp_n, seq_nth_eq, _⟩
[GOAL]
case intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
ifp_n : IntFractPair K
seq_nth_eq : IntFractPair.stream v n = some ifp_n
left✝ : ifp_n.fr ≠ 0
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some (IntFractPair.of ifp_n.fr⁻¹)
succ_nth_fr_eq_zero : (IntFractPair.of ifp_n.fr⁻¹).fr = 0
⊢ ifp_n.fr⁻¹ = ↑⌊ifp_n.fr⁻¹⌋
[PROOFSTEP]
simpa only [IntFractPair.of, Int.fract, sub_eq_zero] using succ_nth_fr_eq_zero
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
h : Int.fract v ≠ 0
n : ℕ
⊢ IntFractPair.stream v (n + 1) = IntFractPair.stream (Int.fract v)⁻¹ n
[PROOFSTEP]
induction' n with n ih
[GOAL]
case zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
h : Int.fract v ≠ 0
⊢ IntFractPair.stream v (Nat.zero + 1) = IntFractPair.stream (Int.fract v)⁻¹ Nat.zero
[PROOFSTEP]
have H : (IntFractPair.of v).fr = Int.fract v := rfl
[GOAL]
case zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
h : Int.fract v ≠ 0
H : (IntFractPair.of v).fr = Int.fract v
⊢ IntFractPair.stream v (Nat.zero + 1) = IntFractPair.stream (Int.fract v)⁻¹ Nat.zero
[PROOFSTEP]
rw [stream_zero, stream_succ_of_some (stream_zero v) (ne_of_eq_of_ne H h), H]
[GOAL]
case succ
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
h : Int.fract v ≠ 0
n : ℕ
ih : IntFractPair.stream v (n + 1) = IntFractPair.stream (Int.fract v)⁻¹ n
⊢ IntFractPair.stream v (Nat.succ n + 1) = IntFractPair.stream (Int.fract v)⁻¹ (Nat.succ n)
[PROOFSTEP]
cases' eq_or_ne (IntFractPair.stream (Int.fract v)⁻¹ n) none with hnone hsome
[GOAL]
case succ.inl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
h : Int.fract v ≠ 0
n : ℕ
ih : IntFractPair.stream v (n + 1) = IntFractPair.stream (Int.fract v)⁻¹ n
hnone : IntFractPair.stream (Int.fract v)⁻¹ n = none
⊢ IntFractPair.stream v (Nat.succ n + 1) = IntFractPair.stream (Int.fract v)⁻¹ (Nat.succ n)
[PROOFSTEP]
rw [hnone] at ih
[GOAL]
case succ.inl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
h : Int.fract v ≠ 0
n : ℕ
ih : IntFractPair.stream v (n + 1) = none
hnone : IntFractPair.stream (Int.fract v)⁻¹ n = none
⊢ IntFractPair.stream v (Nat.succ n + 1) = IntFractPair.stream (Int.fract v)⁻¹ (Nat.succ n)
[PROOFSTEP]
rw [succ_nth_stream_eq_none_iff.mpr (Or.inl hnone), succ_nth_stream_eq_none_iff.mpr (Or.inl ih)]
[GOAL]
case succ.inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
h : Int.fract v ≠ 0
n : ℕ
ih : IntFractPair.stream v (n + 1) = IntFractPair.stream (Int.fract v)⁻¹ n
hsome : IntFractPair.stream (Int.fract v)⁻¹ n ≠ none
⊢ IntFractPair.stream v (Nat.succ n + 1) = IntFractPair.stream (Int.fract v)⁻¹ (Nat.succ n)
[PROOFSTEP]
obtain ⟨p, hp⟩ := Option.ne_none_iff_exists'.mp hsome
[GOAL]
case succ.inr.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
h : Int.fract v ≠ 0
n : ℕ
ih : IntFractPair.stream v (n + 1) = IntFractPair.stream (Int.fract v)⁻¹ n
hsome : IntFractPair.stream (Int.fract v)⁻¹ n ≠ none
p : IntFractPair K
hp : IntFractPair.stream (Int.fract v)⁻¹ n = some p
⊢ IntFractPair.stream v (Nat.succ n + 1) = IntFractPair.stream (Int.fract v)⁻¹ (Nat.succ n)
[PROOFSTEP]
rw [hp] at ih
[GOAL]
case succ.inr.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
h : Int.fract v ≠ 0
n : ℕ
hsome : IntFractPair.stream (Int.fract v)⁻¹ n ≠ none
p : IntFractPair K
ih : IntFractPair.stream v (n + 1) = some p
hp : IntFractPair.stream (Int.fract v)⁻¹ n = some p
⊢ IntFractPair.stream v (Nat.succ n + 1) = IntFractPair.stream (Int.fract v)⁻¹ (Nat.succ n)
[PROOFSTEP]
cases' eq_or_ne p.fr 0 with hz hnz
[GOAL]
case succ.inr.intro.inl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
h : Int.fract v ≠ 0
n : ℕ
hsome : IntFractPair.stream (Int.fract v)⁻¹ n ≠ none
p : IntFractPair K
ih : IntFractPair.stream v (n + 1) = some p
hp : IntFractPair.stream (Int.fract v)⁻¹ n = some p
hz : p.fr = 0
⊢ IntFractPair.stream v (Nat.succ n + 1) = IntFractPair.stream (Int.fract v)⁻¹ (Nat.succ n)
[PROOFSTEP]
rw [stream_eq_none_of_fr_eq_zero hp hz, stream_eq_none_of_fr_eq_zero ih hz]
[GOAL]
case succ.inr.intro.inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
h : Int.fract v ≠ 0
n : ℕ
hsome : IntFractPair.stream (Int.fract v)⁻¹ n ≠ none
p : IntFractPair K
ih : IntFractPair.stream v (n + 1) = some p
hp : IntFractPair.stream (Int.fract v)⁻¹ n = some p
hnz : p.fr ≠ 0
⊢ IntFractPair.stream v (Nat.succ n + 1) = IntFractPair.stream (Int.fract v)⁻¹ (Nat.succ n)
[PROOFSTEP]
rw [stream_succ_of_some hp hnz, stream_succ_of_some ih hnz]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
⊢ (of v).h = ↑(IntFractPair.seq1 v).fst.b
[PROOFSTEP]
cases aux_seq_eq : IntFractPair.seq1 v
[GOAL]
case mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
fst✝ : IntFractPair K
snd✝ : Stream'.Seq (IntFractPair K)
aux_seq_eq : IntFractPair.seq1 v = (fst✝, snd✝)
⊢ (of v).h = ↑(fst✝, snd✝).fst.b
[PROOFSTEP]
simp [of, aux_seq_eq]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
⊢ (of v).h = ↑⌊v⌋
[PROOFSTEP]
simp [of_h_eq_intFractPair_seq1_fst_b, IntFractPair.of]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
⊢ TerminatedAt (of v) n ↔ IntFractPair.stream v (n + 1) = none
[PROOFSTEP]
rw [of_terminatedAt_iff_intFractPair_seq1_terminatedAt, Stream'.Seq.TerminatedAt,
IntFractPair.get?_seq1_eq_succ_get?_stream]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
gp_n : Pair K
s_nth_eq : Stream'.Seq.get? (of v).s n = some gp_n
⊢ ∃ ifp, IntFractPair.stream v (n + 1) = some ifp ∧ ↑ifp.b = gp_n.b
[PROOFSTEP]
obtain ⟨ifp, stream_succ_nth_eq, gp_n_eq⟩ :
∃ ifp, IntFractPair.stream v (n + 1) = some ifp ∧ Pair.mk 1 (ifp.b : K) = gp_n :=
by
unfold of IntFractPair.seq1 at s_nth_eq
simpa [Stream'.Seq.get?_tail, Stream'.Seq.map_get?] using s_nth_eq
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
gp_n : Pair K
s_nth_eq : Stream'.Seq.get? (of v).s n = some gp_n
⊢ ∃ ifp, IntFractPair.stream v (n + 1) = some ifp ∧ { a := 1, b := ↑ifp.b } = gp_n
[PROOFSTEP]
unfold of IntFractPair.seq1 at s_nth_eq
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
gp_n : Pair K
s_nth_eq :
Stream'.Seq.get?
(match
(IntFractPair.of v,
Stream'.Seq.tail
{ val := IntFractPair.stream v, property := (_ : Stream'.IsSeq (IntFractPair.stream v)) }) with
| (h, s) => { h := ↑h.b, s := Stream'.Seq.map (fun p => { a := 1, b := ↑p.b }) s }).s
n =
some gp_n
⊢ ∃ ifp, IntFractPair.stream v (n + 1) = some ifp ∧ { a := 1, b := ↑ifp.b } = gp_n
[PROOFSTEP]
simpa [Stream'.Seq.get?_tail, Stream'.Seq.map_get?] using s_nth_eq
[GOAL]
case intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
gp_n : Pair K
s_nth_eq : Stream'.Seq.get? (of v).s n = some gp_n
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
gp_n_eq : { a := 1, b := ↑ifp.b } = gp_n
⊢ ∃ ifp, IntFractPair.stream v (n + 1) = some ifp ∧ ↑ifp.b = gp_n.b
[PROOFSTEP]
cases gp_n_eq
[GOAL]
case intro.intro.refl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
ifp : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp
s_nth_eq : Stream'.Seq.get? (of v).s n = some { a := 1, b := ↑ifp.b }
⊢ ∃ ifp_1, IntFractPair.stream v (n + 1) = some ifp_1 ∧ ↑ifp_1.b = { a := 1, b := ↑ifp.b }.b
[PROOFSTEP]
simp_all only [Option.some.injEq, exists_eq_left']
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
ifp_succ_n : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n
⊢ Stream'.Seq.get? (of v).s n = some { a := 1, b := ↑ifp_succ_n.b }
[PROOFSTEP]
unfold of IntFractPair.seq1
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
ifp_succ_n : IntFractPair K
stream_succ_nth_eq : IntFractPair.stream v (n + 1) = some ifp_succ_n
⊢ Stream'.Seq.get?
(match
(IntFractPair.of v,
Stream'.Seq.tail
{ val := IntFractPair.stream v, property := (_ : Stream'.IsSeq (IntFractPair.stream v)) }) with
| (h, s) => { h := ↑h.b, s := Stream'.Seq.map (fun p => { a := 1, b := ↑p.b }) s }).s
n =
some { a := 1, b := ↑ifp_succ_n.b }
[PROOFSTEP]
simp [Stream'.Seq.map_tail, Stream'.Seq.get?_tail, Stream'.Seq.map_get?, stream_succ_nth_eq]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
ifp_n : IntFractPair K
stream_nth_eq : IntFractPair.stream v n = some ifp_n
nth_fr_ne_zero : ifp_n.fr ≠ 0
⊢ IntFractPair.stream v (n + 1) = some (IntFractPair.of ifp_n.fr⁻¹)
[PROOFSTEP]
cases ifp_n
[GOAL]
case mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
b✝ : ℤ
fr✝ : K
stream_nth_eq : IntFractPair.stream v n = some { b := b✝, fr := fr✝ }
nth_fr_ne_zero : { b := b✝, fr := fr✝ }.fr ≠ 0
⊢ IntFractPair.stream v (n + 1) = some (IntFractPair.of { b := b✝, fr := fr✝ }.fr⁻¹)
[PROOFSTEP]
simp [IntFractPair.stream, stream_nth_eq, nth_fr_ne_zero]
[GOAL]
case mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
b✝ : ℤ
fr✝ : K
stream_nth_eq : IntFractPair.stream v n = some { b := b✝, fr := fr✝ }
nth_fr_ne_zero : { b := b✝, fr := fr✝ }.fr ≠ 0
⊢ fr✝ = 0 → False
[PROOFSTEP]
intro
[GOAL]
case mk
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
b✝ : ℤ
fr✝ : K
stream_nth_eq : IntFractPair.stream v n = some { b := b✝, fr := fr✝ }
nth_fr_ne_zero : { b := b✝, fr := fr✝ }.fr ≠ 0
a✝ : fr✝ = 0
⊢ False
[PROOFSTEP]
contradiction
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
n : ℕ
v : K
⊢ Stream'.Seq.get? (of v).s 0 = Option.bind (IntFractPair.stream v 1) (some ∘ fun p => { a := 1, b := ↑p.b })
[PROOFSTEP]
rw [of, IntFractPair.seq1]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
n : ℕ
v : K
⊢ Stream'.Seq.get?
(match
(IntFractPair.of v,
Stream'.Seq.tail
{ val := IntFractPair.stream v, property := (_ : Stream'.IsSeq (IntFractPair.stream v)) }) with
| (h, s) => { h := ↑h.b, s := Stream'.Seq.map (fun p => { a := 1, b := ↑p.b }) s }).s
0 =
Option.bind (IntFractPair.stream v 1) (some ∘ fun p => { a := 1, b := ↑p.b })
[PROOFSTEP]
simp only [of, Stream'.Seq.map_tail, Stream'.Seq.map, Stream'.Seq.tail, Stream'.Seq.head, Stream'.Seq.get?, Stream'.map]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
n : ℕ
v : K
⊢ Option.map (fun p => { a := 1, b := ↑p.b }) (Stream'.nth (Stream'.tail (IntFractPair.stream v)) 0) =
Option.bind (IntFractPair.stream v 1) (some ∘ fun p => { a := 1, b := ↑p.b })
[PROOFSTEP]
rw [← Stream'.nth_succ, Stream'.nth, Option.map]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
n : ℕ
v : K
⊢ (match IntFractPair.stream v (Nat.succ 0) with
| some x => some { a := 1, b := ↑x.b }
| none => none) =
Option.bind (IntFractPair.stream v 1) (some ∘ fun p => { a := 1, b := ↑p.b })
[PROOFSTEP]
split
[GOAL]
case h_1
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
n : ℕ
v : K
x✝¹ : Option (IntFractPair K)
x✝ : IntFractPair K
heq✝ : IntFractPair.stream v (Nat.succ 0) = some x✝
⊢ some { a := 1, b := ↑x✝.b } = Option.bind (IntFractPair.stream v 1) (some ∘ fun p => { a := 1, b := ↑p.b })
[PROOFSTEP]
simp_all only [Option.some_bind, Option.none_bind, Function.comp_apply]
[GOAL]
case h_2
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v✝ : K
n : ℕ
v : K
x✝ : Option (IntFractPair K)
heq✝ : IntFractPair.stream v (Nat.succ 0) = none
⊢ none = Option.bind (IntFractPair.stream v 1) (some ∘ fun p => { a := 1, b := ↑p.b })
[PROOFSTEP]
simp_all only [Option.some_bind, Option.none_bind, Function.comp_apply]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
h : fract v ≠ 0
⊢ Stream'.Seq.head (of v).s = some { a := 1, b := ↑⌊(fract v)⁻¹⌋ }
[PROOFSTEP]
change (of v).s.get? 0 = _
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
h : fract v ≠ 0
⊢ Stream'.Seq.get? (of v).s 0 = some { a := 1, b := ↑⌊(fract v)⁻¹⌋ }
[PROOFSTEP]
rw [of_s_head_aux, stream_succ_of_some (stream_zero v) h, Option.bind]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
h : fract v ≠ 0
⊢ (match some (IntFractPair.of (IntFractPair.of v).fr⁻¹), some ∘ fun p => { a := 1, b := ↑p.b } with
| none, x => none
| some a, b => b a) =
some { a := 1, b := ↑⌊(fract v)⁻¹⌋ }
[PROOFSTEP]
rfl
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
a : ℤ
⊢ ∀ (n : ℕ), Stream'.Seq.get? (of ↑a).s n = none
[PROOFSTEP]
intro n
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
a : ℤ
n : ℕ
⊢ Stream'.Seq.get? (of ↑a).s n = none
[PROOFSTEP]
induction' n with n ih
[GOAL]
case zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
a : ℤ
⊢ Stream'.Seq.get? (of ↑a).s Nat.zero = none
[PROOFSTEP]
rw [of_s_head_aux, stream_succ_of_int, Option.bind]
[GOAL]
case succ
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
a : ℤ
n : ℕ
ih : Stream'.Seq.get? (of ↑a).s n = none
⊢ Stream'.Seq.get? (of ↑a).s (Nat.succ n) = none
[PROOFSTEP]
exact (of (a : K)).s.prop ih
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n
[PROOFSTEP]
cases' eq_or_ne (fract v) 0 with h h
[GOAL]
case inl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v = 0
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n
[PROOFSTEP]
obtain ⟨a, rfl⟩ : ∃ a : ℤ, v = a := ⟨⌊v⌋, eq_of_sub_eq_zero h⟩
[GOAL]
case inl.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n✝ n : ℕ
a : ℤ
h : fract ↑a = 0
⊢ Stream'.Seq.get? (of ↑a).s (n + 1) = Stream'.Seq.get? (of (fract ↑a)⁻¹).s n
[PROOFSTEP]
rw [fract_intCast, inv_zero, of_s_of_int, ← cast_zero, of_s_of_int, Stream'.Seq.get?_nil, Stream'.Seq.get?_nil]
[GOAL]
case inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n
[PROOFSTEP]
cases' eq_or_ne ((of (fract v)⁻¹).s.get? n) none with h₁ h₁
[GOAL]
case inr.inl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n = none
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n
[PROOFSTEP]
rwa [h₁, ← terminatedAt_iff_s_none, of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none, stream_succ h, ←
of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none, terminatedAt_iff_s_none]
[GOAL]
case inr.inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n ≠ none
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n
[PROOFSTEP]
obtain ⟨p, hp⟩ := Option.ne_none_iff_exists'.mp h₁
[GOAL]
case inr.inr.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n ≠ none
p : Pair K
hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some p
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n
[PROOFSTEP]
obtain ⟨p', hp'₁, _⟩ := exists_succ_get?_stream_of_gcf_of_get?_eq_some hp
[GOAL]
case inr.inr.intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n ≠ none
p : Pair K
hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some p
p' : IntFractPair K
hp'₁ : IntFractPair.stream (fract v)⁻¹ (n + 1) = some p'
right✝ : ↑p'.b = p.b
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n
[PROOFSTEP]
have Hp := get?_of_eq_some_of_succ_get?_intFractPair_stream hp'₁
[GOAL]
case inr.inr.intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n ≠ none
p : Pair K
hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some p
p' : IntFractPair K
hp'₁ : IntFractPair.stream (fract v)⁻¹ (n + 1) = some p'
right✝ : ↑p'.b = p.b
Hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some { a := 1, b := ↑p'.b }
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n
[PROOFSTEP]
rw [← stream_succ h] at hp'₁
[GOAL]
case inr.inr.intro.intro.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ n : ℕ
h : fract v ≠ 0
h₁ : Stream'.Seq.get? (of (fract v)⁻¹).s n ≠ none
p : Pair K
hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some p
p' : IntFractPair K
hp'₁ : IntFractPair.stream v (n + 1 + 1) = some p'
right✝ : ↑p'.b = p.b
Hp : Stream'.Seq.get? (of (fract v)⁻¹).s n = some { a := 1, b := ↑p'.b }
⊢ Stream'.Seq.get? (of v).s (n + 1) = Stream'.Seq.get? (of (fract v)⁻¹).s n
[PROOFSTEP]
rw [Hp, get?_of_eq_some_of_succ_get?_intFractPair_stream hp'₁]
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
a : ℤ
⊢ convergents' (of ↑a) n = ↑a
[PROOFSTEP]
induction' n with n
[GOAL]
case zero
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
a : ℤ
⊢ convergents' (of ↑a) Nat.zero = ↑a
[PROOFSTEP]
simp only [zeroth_convergent'_eq_h, of_h_eq_floor, floor_intCast, Nat.zero_eq]
[GOAL]
case succ
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
a : ℤ
n : ℕ
n_ih✝ : convergents' (of ↑a) n = ↑a
⊢ convergents' (of ↑a) (Nat.succ n) = ↑a
[PROOFSTEP]
rw [convergents', of_h_eq_floor, floor_intCast, add_right_eq_self]
[GOAL]
case succ
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n✝ : ℕ
a : ℤ
n : ℕ
n_ih✝ : convergents' (of ↑a) n = ↑a
⊢ convergents'Aux (of ↑a).s (Nat.succ n) = 0
[PROOFSTEP]
exact convergents'Aux_succ_none ((of_s_of_int K a).symm ▸ Stream'.Seq.get?_nil 0) _
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
⊢ convergents' (of v) (n + 1) = ↑⌊v⌋ + 1 / convergents' (of (fract v)⁻¹) n
[PROOFSTEP]
cases' eq_or_ne (fract v) 0 with h h
[GOAL]
case inl
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
h : fract v = 0
⊢ convergents' (of v) (n + 1) = ↑⌊v⌋ + 1 / convergents' (of (fract v)⁻¹) n
[PROOFSTEP]
obtain ⟨a, rfl⟩ : ∃ a : ℤ, v = a := ⟨⌊v⌋, eq_of_sub_eq_zero h⟩
[GOAL]
case inl.intro
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
n : ℕ
a : ℤ
h : fract ↑a = 0
⊢ convergents' (of ↑a) (n + 1) = ↑⌊↑a⌋ + 1 / convergents' (of (fract ↑a)⁻¹) n
[PROOFSTEP]
rw [convergents'_of_int, fract_intCast, inv_zero, ← cast_zero, convergents'_of_int, cast_zero, div_zero, add_zero,
floor_intCast]
[GOAL]
case inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
h : fract v ≠ 0
⊢ convergents' (of v) (n + 1) = ↑⌊v⌋ + 1 / convergents' (of (fract v)⁻¹) n
[PROOFSTEP]
rw [convergents', of_h_eq_floor, add_right_inj, convergents'Aux_succ_some (of_s_head h)]
[GOAL]
case inr
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
h : fract v ≠ 0
⊢ { a := 1, b := ↑⌊(fract v)⁻¹⌋ }.a /
({ a := 1, b := ↑⌊(fract v)⁻¹⌋ }.b + convergents'Aux (Stream'.Seq.tail (of v).s) n) =
1 / convergents' (of (fract v)⁻¹) n
[PROOFSTEP]
exact congr_arg ((· / ·) 1) (by rw [convergents', of_h_eq_floor, add_right_inj, of_s_tail])
[GOAL]
K : Type u_1
inst✝¹ : LinearOrderedField K
inst✝ : FloorRing K
v : K
n : ℕ
h : fract v ≠ 0
⊢ { a := 1, b := ↑⌊(fract v)⁻¹⌋ }.b + convergents'Aux (Stream'.Seq.tail (of v).s) n = convergents' (of (fract v)⁻¹) n
[PROOFSTEP]
rw [convergents', of_h_eq_floor, add_right_inj, of_s_tail]
|
function [pf,f]=lpccc2pf(cc,np,nc,c0)
%LPCCC2PF Convert complex cepstrum to power spectrum PF=(CC,NP,NC)
%
% Inputs: cc(nf,n) Complex ceptral coefficients excluding c(0), one frame per row
% np Size of output spectrum is np+1 [n]
% Alternatively, np can be a vector of output frequencies in the range 0 to 0.5
% nc Highest cepstral coefficient to use [np or, if np is a vector, n]
% Set nc=-1 to use n coefficients
% c0(nf,1) Cepstral coefficient cc(0) [0]
%
% Outputs: pf(nf,np+1) Power spectrum from DC to Nyquist
% f(1,np+1) Normalized frequencies (0 to 0.5)
%
% The "complex cepstral coefficients", cc(n), are the inverse discrete-time Fourier transform
% of the log of the complex-valued spectrum. The cc(n) are real-valued and, for n<0, cc(n)=0.
% The "real cepstral coeffcients", rc(n), are the inverse discrete-time Fourier transform
% of the log of the magnitude spectrum; rc(0)=cc(0) and rc(n)=0.5*cc(n) for n~=0.
% For highest speed, choose np to be a power of 2.
% Copyright (C) Mike Brookes 1998-2014
% Version: $Id: lpccc2pf.m 5026 2014-08-22 17:47:43Z dmb $
%
% VOICEBOX is a MATLAB toolbox for speech processing.
% Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You can obtain a copy of the GNU General Public License from
% http://www.gnu.org/copyleft/gpl.html or by writing to
% Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[nf,mc]=size(cc);
if nargin<2 || ~numel(np)
if nargout
np=mc;
else
np=128;
end
end
if nargin>=3 && numel(nc)==1 && nc==-1 nc=mc; end
if nargin<4 || ~numel(c0) c0=zeros(nf,1); end
if numel(np)>1 || np(1)<1
if nargin<3 || ~numel(nc) nc=mc; end
f=np(:)';
if nc==mc
pf=exp(2*[c0 cc]*cos(2*pi*(0:mc)'*f));
else
pf=exp(2*[c0 lpccc2cc(cc,nc)]*cos(2*pi*(0:nc)'*f));
end
else
if nargin<3 || ~numel(nc) nc=np; end
if nc==mc
pf=exp(2*real(rfft([c0 cc].',2*np).'));
else
pf=exp(2*real(rfft([c0 lpccc2cc(cc,nc)].',2*np).'));
end
f=linspace(0,0.5,np+1);
end
if ~nargout
plot(f,db(pf.')/2);
xlabel('Normalized frequency f/f_s');
ylabel('Gain (dB)');
end
|
theory T111
imports Main
begin
lemma "(
(\<forall> x::nat. \<forall> y::nat. meet(x, y) = meet(y, x)) &
(\<forall> x::nat. \<forall> y::nat. join(x, y) = join(y, x)) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(x, meet(y, z)) = meet(meet(x, y), z)) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(x, join(y, z)) = join(join(x, y), z)) &
(\<forall> x::nat. \<forall> y::nat. meet(x, join(x, y)) = x) &
(\<forall> x::nat. \<forall> y::nat. join(x, meet(x, y)) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(x, join(y, z)) = join(mult(x, y), mult(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(join(x, y), z) = join(mult(x, z), mult(y, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(x, over(join(mult(x, y), z), y)) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(y, undr(x, join(mult(x, y), z))) = y) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(mult(over(x, y), y), x) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(mult(y, undr(y, x)), x) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(x, meet(y, z)) = meet(mult(x, y), mult(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. undr(x, join(y, z)) = join(undr(x, y), undr(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. over(x, meet(y, z)) = join(over(x, y), over(x, z))) &
(\<forall> x::nat. \<forall> y::nat. invo(join(x, y)) = meet(invo(x), invo(y))) &
(\<forall> x::nat. \<forall> y::nat. invo(meet(x, y)) = join(invo(x), invo(y))) &
(\<forall> x::nat. invo(invo(x)) = x)
) \<longrightarrow>
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. over(join(x, y), z) = join(over(x, z), over(y, z)))
"
nitpick[card nat=8,timeout=86400]
oops
end |
section \<open>Prisms\<close>
theory Prisms
imports Lenses
begin
subsection \<open> Signature and Axioms \<close>
text \<open>Prisms are like lenses, but they act on sum types rather than product types~\<^cite>\<open>"Gibbons17"\<close>.
See \url{https://hackage.haskell.org/package/lens-4.15.2/docs/Control-Lens-Prism.html}
for more information.\<close>
record ('v, 's) prism =
prism_match :: "'s \<Rightarrow> 'v option" ("match\<index>")
prism_build :: "'v \<Rightarrow> 's" ("build\<index>")
type_notation
prism (infixr "\<Longrightarrow>\<^sub>\<triangle>" 0)
locale wb_prism =
fixes x :: "'v \<Longrightarrow>\<^sub>\<triangle> 's" (structure)
assumes match_build: "match (build v) = Some v"
and build_match: "match s = Some v \<Longrightarrow> s = build v"
begin
lemma build_match_iff: "match s = Some v \<longleftrightarrow> s = build v"
using build_match match_build by blast
lemma range_build: "range build = dom match"
using build_match match_build by fastforce
lemma inj_build: "inj build"
by (metis injI match_build option.inject)
end
declare wb_prism.match_build [simp]
declare wb_prism.build_match [simp]
subsection \<open> Co-dependence \<close>
text \<open> The relation states that two prisms construct disjoint elements of the source. This
can occur, for example, when the two prisms characterise different constructors of an
algebraic datatype. \<close>
definition prism_diff :: "('a \<Longrightarrow>\<^sub>\<triangle> 's) \<Rightarrow> ('b \<Longrightarrow>\<^sub>\<triangle> 's) \<Rightarrow> bool" (infix "\<nabla>" 50) where
[lens_defs]: "prism_diff X Y = (range build\<^bsub>X\<^esub> \<inter> range build\<^bsub>Y\<^esub> = {})"
lemma prism_diff_intro:
"(\<And> s\<^sub>1 s\<^sub>2. build\<^bsub>X\<^esub> s\<^sub>1 = build\<^bsub>Y\<^esub> s\<^sub>2 \<Longrightarrow> False) \<Longrightarrow> X \<nabla> Y"
by (auto simp add: prism_diff_def)
lemma prism_diff_irrefl: "\<not> X \<nabla> X"
by (simp add: prism_diff_def)
lemma prism_diff_sym: "X \<nabla> Y \<Longrightarrow> Y \<nabla> X"
by (auto simp add: prism_diff_def)
lemma prism_diff_build: "X \<nabla> Y \<Longrightarrow> build\<^bsub>X\<^esub> u \<noteq> build\<^bsub>Y\<^esub> v"
by (simp add: disjoint_iff_not_equal prism_diff_def)
lemma prism_diff_build_match: "\<lbrakk> wb_prism X; X \<nabla> Y \<rbrakk> \<Longrightarrow> match\<^bsub>X\<^esub> (build\<^bsub>Y\<^esub> v) = None"
using UNIV_I wb_prism.range_build by (fastforce simp add: prism_diff_def)
subsection \<open> Canonical prisms \<close>
definition prism_id :: "('a \<Longrightarrow>\<^sub>\<triangle> 'a)" ("1\<^sub>\<triangle>") where
[lens_defs]: "prism_id = \<lparr> prism_match = Some, prism_build = id \<rparr>"
lemma wb_prism_id: "wb_prism 1\<^sub>\<triangle>"
unfolding prism_id_def wb_prism_def by simp
lemma prism_id_never_diff: "\<not> 1\<^sub>\<triangle> \<nabla> X"
by (simp add: prism_diff_def prism_id_def)
subsection \<open> Summation \<close>
definition prism_plus :: "('a \<Longrightarrow>\<^sub>\<triangle> 's) \<Rightarrow> ('b \<Longrightarrow>\<^sub>\<triangle> 's) \<Rightarrow> 'a + 'b \<Longrightarrow>\<^sub>\<triangle> 's" (infixl "+\<^sub>\<triangle>" 85)
where
[lens_defs]: "X +\<^sub>\<triangle> Y = \<lparr> prism_match = (\<lambda> s. case (match\<^bsub>X\<^esub> s, match\<^bsub>Y\<^esub> s) of
(Some u, _) \<Rightarrow> Some (Inl u) |
(None, Some v) \<Rightarrow> Some (Inr v) |
(None, None) \<Rightarrow> None),
prism_build = (\<lambda> v. case v of Inl x \<Rightarrow> build\<^bsub>X\<^esub> x | Inr y \<Rightarrow> build\<^bsub>Y\<^esub> y) \<rparr>"
lemma prism_plus_wb [simp]: "\<lbrakk> wb_prism X; wb_prism Y; X \<nabla> Y \<rbrakk> \<Longrightarrow> wb_prism (X +\<^sub>\<triangle> Y)"
apply (unfold_locales)
apply (auto simp add: prism_plus_def sum.case_eq_if option.case_eq_if prism_diff_build_match)
apply (metis map_option_case map_option_eq_Some option.exhaust option.sel sum.disc(2) sum.sel(1) wb_prism.build_match_iff)
apply (metis (no_types, lifting) isl_def not_None_eq option.case_eq_if option.sel sum.sel(2) wb_prism.build_match)
done
lemma build_plus_Inl [simp]: "build\<^bsub>c +\<^sub>\<triangle> d\<^esub> (Inl x) = build\<^bsub>c\<^esub> x"
by (simp add: prism_plus_def)
lemma build_plus_Inr [simp]: "build\<^bsub>c +\<^sub>\<triangle> d\<^esub> (Inr y) = build\<^bsub>d\<^esub> y"
by (simp add: prism_plus_def)
lemma prism_diff_preserved_1 [simp]: "\<lbrakk> X \<nabla> Y; X \<nabla> Z \<rbrakk> \<Longrightarrow> X \<nabla> Y +\<^sub>\<triangle> Z"
by (auto simp add: lens_defs sum.case_eq_if)
lemma prism_diff_preserved_2 [simp]: "\<lbrakk> X \<nabla> Z; Y \<nabla> Z \<rbrakk> \<Longrightarrow> X +\<^sub>\<triangle> Y \<nabla> Z"
by (meson prism_diff_preserved_1 prism_diff_sym)
text \<open> The following two lemmas are useful for reasoning about prism sums \<close>
lemma Bex_Sum_iff: "(\<exists>x\<in>A<+>B. P x) \<longleftrightarrow> (\<exists> x\<in>A. P (Inl x)) \<or> (\<exists> y\<in>B. P (Inr y))"
by (auto)
lemma Ball_Sum_iff: "(\<forall>x\<in>A<+>B. P x) \<longleftrightarrow> (\<forall> x\<in>A. P (Inl x)) \<and> (\<forall> y\<in>B. P (Inr y))"
by (auto)
subsection \<open> Instances \<close>
definition prism_suml :: "('a, 'a + 'b) prism" ("Inl\<^sub>\<triangle>") where
[lens_defs]: "prism_suml = \<lparr> prism_match = (\<lambda> v. case v of Inl x \<Rightarrow> Some x | _ \<Rightarrow> None), prism_build = Inl \<rparr>"
definition prism_sumr :: "('b, 'a + 'b) prism" ("Inr\<^sub>\<triangle>") where
[lens_defs]: "prism_sumr = \<lparr> prism_match = (\<lambda> v. case v of Inr x \<Rightarrow> Some x | _ \<Rightarrow> None), prism_build = Inr \<rparr>"
lemma wb_prim_suml [simp]: "wb_prism Inl\<^sub>\<triangle>"
apply (unfold_locales)
apply (simp_all add: prism_suml_def sum.case_eq_if)
apply (metis option.inject option.simps(3) sum.collapse(1))
done
lemma wb_prim_sumr [simp]: "wb_prism Inr\<^sub>\<triangle>"
apply (unfold_locales)
apply (simp_all add: prism_sumr_def sum.case_eq_if)
apply (metis option.distinct(1) option.inject sum.collapse(2))
done
lemma prism_suml_indep_sumr [simp]: "Inl\<^sub>\<triangle> \<nabla> Inr\<^sub>\<triangle>"
by (auto simp add: lens_defs)
lemma prism_sum_plus: "Inl\<^sub>\<triangle> +\<^sub>\<triangle> Inr\<^sub>\<triangle> = 1\<^sub>\<triangle>"
unfolding lens_defs prism_plus_def by (auto simp add: Inr_Inl_False sum.case_eq_if)
subsection \<open> Lens correspondence \<close>
text \<open> Every well-behaved prism can be represented by a partial bijective lens. We prove
this by exhibiting conversion functions and showing they are (almost) inverses. \<close>
definition prism_lens :: "('a, 's) prism \<Rightarrow> ('a \<Longrightarrow> 's)" where
"prism_lens X = \<lparr> lens_get = (\<lambda> s. the (match\<^bsub>X\<^esub> s)), lens_put = (\<lambda> s v. build\<^bsub>X\<^esub> v) \<rparr>"
definition lens_prism :: "('a \<Longrightarrow> 's) \<Rightarrow> ('a, 's) prism" where
"lens_prism X = \<lparr> prism_match = (\<lambda> s. if (s \<in> \<S>\<^bsub>X\<^esub>) then Some (get\<^bsub>X\<^esub> s) else None)
, prism_build = create\<^bsub>X\<^esub> \<rparr>"
lemma mwb_prism_lens: "wb_prism a \<Longrightarrow> mwb_lens (prism_lens a)"
by (simp add: mwb_lens_axioms_def mwb_lens_def weak_lens_def prism_lens_def)
lemma get_prism_lens: "get\<^bsub>prism_lens X\<^esub> = the \<circ> match\<^bsub>X\<^esub>"
by (simp add: prism_lens_def fun_eq_iff)
lemma src_prism_lens: "\<S>\<^bsub>prism_lens X\<^esub> = range (build\<^bsub>X\<^esub>)"
by (auto simp add: prism_lens_def lens_source_def)
lemma create_prism_lens: "create\<^bsub>prism_lens X\<^esub> = build\<^bsub>X\<^esub>"
by (simp add: prism_lens_def lens_create_def fun_eq_iff)
lemma prism_lens_inverse:
"wb_prism X \<Longrightarrow> lens_prism (prism_lens X) = X"
unfolding lens_prism_def src_prism_lens create_prism_lens get_prism_lens
by (auto intro: prism.equality simp add: fun_eq_iff domIff wb_prism.range_build)
text \<open> Function @{const lens_prism} is almost inverted by @{const prism_lens}. The $put$
functions are identical, but the $get$ functions differ when applied to a source where
the prism @{term X} is undefined. \<close>
lemma lens_prism_put_inverse:
"pbij_lens X \<Longrightarrow> put\<^bsub>prism_lens (lens_prism X)\<^esub> = put\<^bsub>X\<^esub>"
unfolding prism_lens_def lens_prism_def
by (auto simp add: fun_eq_iff pbij_lens.put_is_create)
lemma wb_prism_implies_pbij_lens:
"wb_prism X \<Longrightarrow> pbij_lens (prism_lens X)"
by (unfold_locales, simp_all add: prism_lens_def)
lemma pbij_lens_implies_wb_prism:
assumes "pbij_lens X"
shows "wb_prism (lens_prism X)"
proof (unfold_locales)
fix s v
show "match\<^bsub>lens_prism X\<^esub> (build\<^bsub>lens_prism X\<^esub> v) = Some v"
by (simp add: lens_prism_def weak_lens.create_closure assms)
assume a: "match\<^bsub>lens_prism X\<^esub> s = Some v"
show "s = build\<^bsub>lens_prism X\<^esub> v"
proof (cases "s \<in> \<S>\<^bsub>X\<^esub>")
case True
with a assms show ?thesis
by (simp add: lens_prism_def lens_create_def,
metis mwb_lens.weak_get_put pbij_lens.put_det pbij_lens_mwb)
next
case False
with a assms show ?thesis by (simp add: lens_prism_def)
qed
qed
ML_file \<open>Prism_Lib.ML\<close>
end
|
module Parser
import Data.Fuel
%default total
public export
data Parser : Type -> Type -> Type where
Continuation : (i -> Parser i o) -> Parser i o
Finished : Maybe o -> Parser i o
export
runParser : Monad m => Fuel -> m i -> (Parser i o) -> m (Maybe o)
runParser Dry _ _ = pure Nothing
runParser _ _ (Finished result) = pure result
runParser (More rest) input (Continuation parser) = do
c <- input
runParser rest input (parser c)
|
/-
Copyright (c) 2021 Anatole Dedecker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anatole Dedecker, Bhavik Mehta
-/
import measure_theory.integral.interval_integral
import order.filter.at_top_bot
/-!
# Links between an integral and its "improper" version
In its current state, mathlib only knows how to talk about definite ("proper") integrals,
in the sense that it treats integrals over `[x, +∞)` the same as it treats integrals over
`[y, z]`. For example, the integral over `[1, +∞)` is **not** defined to be the limit of
the integral over `[1, x]` as `x` tends to `+∞`, which is known as an **improper integral**.
Indeed, the "proper" definition is stronger than the "improper" one. The usual counterexample
is `x ↦ sin(x)/x`, which has an improper integral over `[1, +∞)` but no definite integral.
Although definite integrals have better properties, they are hardly usable when it comes to
computing integrals on unbounded sets, which is much easier using limits. Thus, in this file,
we prove various ways of studying the proper integral by studying the improper one.
## Definitions
The main definition of this file is `measure_theory.ae_cover`. It is a rather technical
definition whose sole purpose is generalizing and factoring proofs. Given an index type `ι`, a
countably generated filter `l` over `ι`, and an `ι`-indexed family `φ` of subsets of a measurable
space `α` equipped with a measure `μ`, one should think of a hypothesis `hφ : ae_cover μ l φ` as
a sufficient condition for being able to interpret `∫ x, f x ∂μ` (if it exists) as the limit
of `∫ x in φ i, f x ∂μ` as `i` tends to `l`.
When using this definition with a measure restricted to a set `s`, which happens fairly often,
one should not try too hard to use a `ae_cover` of subsets of `s`, as it often makes proofs
more complicated than necessary. See for example the proof of
`measure_theory.integrable_on_Iic_of_interval_integral_norm_tendsto` where we use `(λ x, Ioi x)`
as an `ae_cover` w.r.t. `μ.restrict (Iic b)`, instead of using `(λ x, Ioc x b)`.
## Main statements
- `measure_theory.ae_cover.lintegral_tendsto_of_countably_generated` : if `φ` is a `ae_cover μ l`,
where `l` is a countably generated filter, and if `f` is a measurable `ennreal`-valued function,
then `∫⁻ x in φ n, f x ∂μ` tends to `∫⁻ x, f x ∂μ` as `n` tends to `l`
- `measure_theory.ae_cover.integrable_of_integral_norm_tendsto` : if `φ` is a `ae_cover μ l`,
where `l` is a countably generated filter, if `f` is measurable and integrable on each `φ n`,
and if `∫ x in φ n, ∥f x∥ ∂μ` tends to some `I : ℝ` as n tends to `l`, then `f` is integrable
- `measure_theory.ae_cover.integral_tendsto_of_countably_generated` : if `φ` is a `ae_cover μ l`,
where `l` is a countably generated filter, and if `f` is measurable and integrable (globally),
then `∫ x in φ n, f x ∂μ` tends to `∫ x, f x ∂μ` as `n` tends to `+∞`.
We then specialize these lemmas to various use cases involving intervals, which are frequent
in analysis.
-/
open measure_theory filter set topological_space
open_locale ennreal nnreal topological_space
namespace measure_theory
section ae_cover
variables {α ι : Type*} [measurable_space α] (μ : measure α) (l : filter ι)
/-- A sequence `φ` of subsets of `α` is a `ae_cover` w.r.t. a measure `μ` and a filter `l`
if almost every point (w.r.t. `μ`) of `α` eventually belongs to `φ n` (w.r.t. `l`), and if
each `φ n` is measurable.
This definition is a technical way to avoid duplicating a lot of proofs.
It should be thought of as a sufficient condition for being able to interpret
`∫ x, f x ∂μ` (if it exists) as the limit of `∫ x in φ n, f x ∂μ` as `n` tends to `l`.
See for example `measure_theory.ae_cover.lintegral_tendsto_of_countably_generated`,
`measure_theory.ae_cover.integrable_of_integral_norm_tendsto` and
`measure_theory.ae_cover.integral_tendsto_of_countably_generated`. -/
structure ae_cover (φ : ι → set α) : Prop :=
(ae_eventually_mem : ∀ᵐ x ∂μ, ∀ᶠ i in l, x ∈ φ i)
(measurable : ∀ i, measurable_set $ φ i)
variables {μ} {l}
section preorder_α
variables [preorder α] [topological_space α] [order_closed_topology α]
[opens_measurable_space α] {a b : ι → α}
(ha : tendsto a l at_bot) (hb : tendsto b l at_top)
lemma ae_cover_Icc :
ae_cover μ l (λ i, Icc (a i) (b i)) :=
{ ae_eventually_mem := ae_of_all μ (λ x,
(ha.eventually $ eventually_le_at_bot x).mp $
(hb.eventually $ eventually_ge_at_top x).mono $
λ i hbi hai, ⟨hai, hbi⟩ ),
measurable := λ i, measurable_set_Icc }
lemma ae_cover_Ici :
ae_cover μ l (λ i, Ici $ a i) :=
{ ae_eventually_mem := ae_of_all μ (λ x,
(ha.eventually $ eventually_le_at_bot x).mono $
λ i hai, hai ),
measurable := λ i, measurable_set_Ici }
lemma ae_cover_Iic :
ae_cover μ l (λ i, Iic $ b i) :=
{ ae_eventually_mem := ae_of_all μ (λ x,
(hb.eventually $ eventually_ge_at_top x).mono $
λ i hbi, hbi ),
measurable := λ i, measurable_set_Iic }
end preorder_α
section linear_order_α
variables [linear_order α] [topological_space α] [order_closed_topology α]
[opens_measurable_space α] {a b : ι → α}
(ha : tendsto a l at_bot) (hb : tendsto b l at_top)
lemma ae_cover_Ioo [no_min_order α] [no_max_order α] :
ae_cover μ l (λ i, Ioo (a i) (b i)) :=
{ ae_eventually_mem := ae_of_all μ (λ x,
(ha.eventually $ eventually_lt_at_bot x).mp $
(hb.eventually $ eventually_gt_at_top x).mono $
λ i hbi hai, ⟨hai, hbi⟩ ),
measurable := λ i, measurable_set_Ioo }
lemma ae_cover_Ioc [no_min_order α] : ae_cover μ l (λ i, Ioc (a i) (b i)) :=
{ ae_eventually_mem := ae_of_all μ (λ x,
(ha.eventually $ eventually_lt_at_bot x).mp $
(hb.eventually $ eventually_ge_at_top x).mono $
λ i hbi hai, ⟨hai, hbi⟩ ),
measurable := λ i, measurable_set_Ioc }
lemma ae_cover_Ico [no_max_order α] : ae_cover μ l (λ i, Ico (a i) (b i)) :=
{ ae_eventually_mem := ae_of_all μ (λ x,
(ha.eventually $ eventually_le_at_bot x).mp $
(hb.eventually $ eventually_gt_at_top x).mono $
λ i hbi hai, ⟨hai, hbi⟩ ),
measurable := λ i, measurable_set_Ico }
lemma ae_cover_Ioi [no_min_order α] :
ae_cover μ l (λ i, Ioi $ a i) :=
{ ae_eventually_mem := ae_of_all μ (λ x,
(ha.eventually $ eventually_lt_at_bot x).mono $
λ i hai, hai ),
measurable := λ i, measurable_set_Ioi }
lemma ae_cover_Iio [no_max_order α] :
ae_cover μ l (λ i, Iio $ b i) :=
{ ae_eventually_mem := ae_of_all μ (λ x,
(hb.eventually $ eventually_gt_at_top x).mono $
λ i hbi, hbi ),
measurable := λ i, measurable_set_Iio }
end linear_order_α
lemma ae_cover.restrict {φ : ι → set α} (hφ : ae_cover μ l φ) {s : set α} :
ae_cover (μ.restrict s) l φ :=
{ ae_eventually_mem := ae_restrict_of_ae hφ.ae_eventually_mem,
measurable := hφ.measurable }
lemma ae_cover_restrict_of_ae_imp {s : set α} {φ : ι → set α}
(hs : measurable_set s) (ae_eventually_mem : ∀ᵐ x ∂μ, x ∈ s → ∀ᶠ n in l, x ∈ φ n)
(measurable : ∀ n, measurable_set $ φ n) :
ae_cover (μ.restrict s) l φ :=
{ ae_eventually_mem := by rwa ae_restrict_iff' hs,
measurable := measurable }
lemma ae_cover.inter_restrict {φ : ι → set α} (hφ : ae_cover μ l φ)
{s : set α} (hs : measurable_set s) :
ae_cover (μ.restrict s) l (λ i, φ i ∩ s) :=
ae_cover_restrict_of_ae_imp hs
(hφ.ae_eventually_mem.mono (λ x hx hxs, hx.mono $ λ i hi, ⟨hi, hxs⟩))
(λ i, (hφ.measurable i).inter hs)
lemma ae_cover.ae_tendsto_indicator {β : Type*} [has_zero β] [topological_space β]
(f : α → β) {φ : ι → set α} (hφ : ae_cover μ l φ) :
∀ᵐ x ∂μ, tendsto (λ i, (φ i).indicator f x) l (𝓝 $ f x) :=
hφ.ae_eventually_mem.mono (λ x hx, tendsto_const_nhds.congr' $
hx.mono $ λ n hn, (indicator_of_mem hn _).symm)
lemma ae_cover.ae_measurable {β : Type*} [measurable_space β] [l.is_countably_generated] [l.ne_bot]
{f : α → β} {φ : ι → set α} (hφ : ae_cover μ l φ)
(hfm : ∀ i, ae_measurable f (μ.restrict $ φ i)) : ae_measurable f μ :=
begin
obtain ⟨u, hu⟩ := l.exists_seq_tendsto,
have := ae_measurable_Union_iff.mpr (λ (n : ℕ), hfm (u n)),
rwa measure.restrict_eq_self_of_ae_mem at this,
filter_upwards [hφ.ae_eventually_mem] with x hx using
let ⟨i, hi⟩ := (hu.eventually hx).exists in mem_Union.mpr ⟨i, hi⟩
end
end ae_cover
lemma ae_cover.comp_tendsto {α ι ι' : Type*} [measurable_space α] {μ : measure α} {l : filter ι}
{l' : filter ι'} {φ : ι → set α} (hφ : ae_cover μ l φ)
{u : ι' → ι} (hu : tendsto u l' l) :
ae_cover μ l' (φ ∘ u) :=
{ ae_eventually_mem := hφ.ae_eventually_mem.mono (λ x hx, hu.eventually hx),
measurable := λ i, hφ.measurable (u i) }
section ae_cover_Union_Inter_encodable
variables {α ι : Type*} [encodable ι]
[measurable_space α] {μ : measure α}
lemma ae_cover.bInter_Ici_ae_cover [semilattice_sup ι] [nonempty ι] {φ : ι → set α}
(hφ : ae_cover μ at_top φ) : ae_cover μ at_top (λ (n : ι), ⋂ k (h : k ∈ Ici n), φ k) :=
{ ae_eventually_mem := hφ.ae_eventually_mem.mono
begin
intros x h,
rw eventually_at_top at *,
rcases h with ⟨i, hi⟩,
use i,
intros j hj,
exact mem_bInter (λ k hk, hi k (le_trans hj hk)),
end,
measurable := λ i, measurable_set.bInter (countable_encodable _) (λ n _, hφ.measurable n) }
end ae_cover_Union_Inter_encodable
section lintegral
variables {α ι : Type*} [measurable_space α] {μ : measure α} {l : filter ι}
private lemma lintegral_tendsto_of_monotone_of_nat {φ : ℕ → set α}
(hφ : ae_cover μ at_top φ) (hmono : monotone φ) {f : α → ℝ≥0∞} (hfm : ae_measurable f μ) :
tendsto (λ i, ∫⁻ x in φ i, f x ∂μ) at_top (𝓝 $ ∫⁻ x, f x ∂μ) :=
let F := λ n, (φ n).indicator f in
have key₁ : ∀ n, ae_measurable (F n) μ, from λ n, hfm.indicator (hφ.measurable n),
have key₂ : ∀ᵐ (x : α) ∂μ, monotone (λ n, F n x), from ae_of_all _
(λ x i j hij, indicator_le_indicator_of_subset (hmono hij) (λ x, zero_le $ f x) x),
have key₃ : ∀ᵐ (x : α) ∂μ, tendsto (λ n, F n x) at_top (𝓝 (f x)), from hφ.ae_tendsto_indicator f,
(lintegral_tendsto_of_tendsto_of_monotone key₁ key₂ key₃).congr
(λ n, lintegral_indicator f (hφ.measurable n))
lemma ae_cover.lintegral_tendsto_of_nat {φ : ℕ → set α} (hφ : ae_cover μ at_top φ)
{f : α → ℝ≥0∞} (hfm : ae_measurable f μ) :
tendsto (λ i, ∫⁻ x in φ i, f x ∂μ) at_top (𝓝 $ ∫⁻ x, f x ∂μ) :=
begin
have lim₁ := lintegral_tendsto_of_monotone_of_nat (hφ.bInter_Ici_ae_cover)
(λ i j hij, bInter_subset_bInter_left (Ici_subset_Ici.mpr hij)) hfm,
have lim₂ := lintegral_tendsto_of_monotone_of_nat (hφ.bUnion_Iic_ae_cover)
(λ i j hij, bUnion_subset_bUnion_left (Iic_subset_Iic.mpr hij)) hfm,
have le₁ := λ n, lintegral_mono_set (bInter_subset_of_mem left_mem_Ici),
have le₂ := λ n, lintegral_mono_set (subset_bUnion_of_mem right_mem_Iic),
exact tendsto_of_tendsto_of_tendsto_of_le_of_le lim₁ lim₂ le₁ le₂
end
lemma ae_cover.lintegral_tendsto_of_countably_generated [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → ℝ≥0∞}
(hfm : ae_measurable f μ) : tendsto (λ i, ∫⁻ x in φ i, f x ∂μ) l (𝓝 $ ∫⁻ x, f x ∂μ) :=
tendsto_of_seq_tendsto (λ u hu, (hφ.comp_tendsto hu).lintegral_tendsto_of_nat hfm)
lemma ae_cover.lintegral_eq_of_tendsto [l.ne_bot] [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → ℝ≥0∞} (I : ℝ≥0∞)
(hfm : ae_measurable f μ) (htendsto : tendsto (λ i, ∫⁻ x in φ i, f x ∂μ) l (𝓝 I)) :
∫⁻ x, f x ∂μ = I :=
tendsto_nhds_unique (hφ.lintegral_tendsto_of_countably_generated hfm) htendsto
lemma ae_cover.supr_lintegral_eq_of_countably_generated [nonempty ι] [l.ne_bot]
[l.is_countably_generated] {φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → ℝ≥0∞}
(hfm : ae_measurable f μ) : (⨆ (i : ι), ∫⁻ x in φ i, f x ∂μ) = ∫⁻ x, f x ∂μ :=
begin
have := hφ.lintegral_tendsto_of_countably_generated hfm,
refine csupr_eq_of_forall_le_of_forall_lt_exists_gt
(λ i, lintegral_mono' measure.restrict_le_self le_rfl) (λ w hw, _),
rcases exists_between hw with ⟨m, hm₁, hm₂⟩,
rcases (eventually_ge_of_tendsto_gt hm₂ this).exists with ⟨i, hi⟩,
exact ⟨i, lt_of_lt_of_le hm₁ hi⟩,
end
end lintegral
section integrable
variables {α ι E : Type*} [measurable_space α] {μ : measure α} {l : filter ι}
[normed_group E] [measurable_space E] [opens_measurable_space E]
lemma ae_cover.integrable_of_lintegral_nnnorm_bounded [l.ne_bot] [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → E} (I : ℝ) (hfm : ae_measurable f μ)
(hbounded : ∀ᶠ i in l, ∫⁻ x in φ i, ∥f x∥₊ ∂μ ≤ ennreal.of_real I) :
integrable f μ :=
begin
refine ⟨hfm, (le_of_tendsto _ hbounded).trans_lt ennreal.of_real_lt_top⟩,
exact hφ.lintegral_tendsto_of_countably_generated
(measurable_nnnorm.comp_ae_measurable hfm).coe_nnreal_ennreal,
end
lemma ae_cover.integrable_of_lintegral_nnnorm_tendsto [l.ne_bot] [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → E} (I : ℝ)
(hfm : ae_measurable f μ)
(htendsto : tendsto (λ i, ∫⁻ x in φ i, ∥f x∥₊ ∂μ) l (𝓝 $ ennreal.of_real I)) :
integrable f μ :=
begin
refine hφ.integrable_of_lintegral_nnnorm_bounded (max 1 (I + 1)) hfm _,
refine htendsto.eventually (ge_mem_nhds _),
refine (ennreal.of_real_lt_of_real_iff (lt_max_of_lt_left zero_lt_one)).2 _,
exact lt_max_of_lt_right (lt_add_one I),
end
lemma ae_cover.integrable_of_lintegral_nnnorm_bounded' [l.ne_bot] [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → E} (I : ℝ≥0) (hfm : ae_measurable f μ)
(hbounded : ∀ᶠ i in l, ∫⁻ x in φ i, ∥f x∥₊ ∂μ ≤ I) :
integrable f μ :=
hφ.integrable_of_lintegral_nnnorm_bounded I hfm
(by simpa only [ennreal.of_real_coe_nnreal] using hbounded)
lemma ae_cover.integrable_of_lintegral_nnnorm_tendsto' [l.ne_bot] [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → E} (I : ℝ≥0)
(hfm : ae_measurable f μ)
(htendsto : tendsto (λ i, ∫⁻ x in φ i, ∥f x∥₊ ∂μ) l (𝓝 I)) :
integrable f μ :=
hφ.integrable_of_lintegral_nnnorm_tendsto I hfm
(by simpa only [ennreal.of_real_coe_nnreal] using htendsto)
lemma ae_cover.integrable_of_integral_norm_bounded [l.ne_bot] [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → E}
(I : ℝ) (hfi : ∀ i, integrable_on f (φ i) μ)
(hbounded : ∀ᶠ i in l, ∫ x in φ i, ∥f x∥ ∂μ ≤ I) :
integrable f μ :=
begin
have hfm : ae_measurable f μ := hφ.ae_measurable (λ i, (hfi i).ae_measurable),
refine hφ.integrable_of_lintegral_nnnorm_bounded I hfm _,
conv at hbounded in (integral _ _)
{ rw integral_eq_lintegral_of_nonneg_ae (ae_of_all _ (λ x, @norm_nonneg E _ (f x)))
hfm.norm.restrict },
conv at hbounded in (ennreal.of_real _) { dsimp, rw ← coe_nnnorm, rw ennreal.of_real_coe_nnreal },
refine hbounded.mono (λ i hi, _),
rw ←ennreal.of_real_to_real (ne_top_of_lt (hfi i).2),
apply ennreal.of_real_le_of_real hi,
end
lemma ae_cover.integrable_of_integral_norm_tendsto [l.ne_bot] [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → E}
(I : ℝ) (hfi : ∀ i, integrable_on f (φ i) μ)
(htendsto : tendsto (λ i, ∫ x in φ i, ∥f x∥ ∂μ) l (𝓝 I)) :
integrable f μ :=
let ⟨I', hI'⟩ := htendsto.is_bounded_under_le in hφ.integrable_of_integral_norm_bounded I' hfi hI'
lemma ae_cover.integrable_of_integral_bounded_of_nonneg_ae [l.ne_bot] [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → ℝ} (I : ℝ)
(hfi : ∀ i, integrable_on f (φ i) μ) (hnng : ∀ᵐ x ∂μ, 0 ≤ f x)
(hbounded : ∀ᶠ i in l, ∫ x in φ i, f x ∂μ ≤ I) :
integrable f μ :=
hφ.integrable_of_integral_norm_bounded I hfi $ hbounded.mono $ λ i hi,
(integral_congr_ae $ ae_restrict_of_ae $ hnng.mono $ λ x, real.norm_of_nonneg).le.trans hi
lemma ae_cover.integrable_of_integral_tendsto_of_nonneg_ae [l.ne_bot] [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → ℝ} (I : ℝ)
(hfi : ∀ i, integrable_on f (φ i) μ) (hnng : ∀ᵐ x ∂μ, 0 ≤ f x)
(htendsto : tendsto (λ i, ∫ x in φ i, f x ∂μ) l (𝓝 I)) :
integrable f μ :=
let ⟨I', hI'⟩ := htendsto.is_bounded_under_le in
hφ.integrable_of_integral_bounded_of_nonneg_ae I' hfi hnng hI'
end integrable
section integral
variables {α ι E : Type*} [measurable_space α] {μ : measure α} {l : filter ι}
[normed_group E] [normed_space ℝ E] [measurable_space E] [borel_space E]
[complete_space E] [second_countable_topology E]
lemma ae_cover.integral_tendsto_of_countably_generated [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → E} (hfi : integrable f μ) :
tendsto (λ i, ∫ x in φ i, f x ∂μ) l (𝓝 $ ∫ x, f x ∂μ) :=
suffices h : tendsto (λ i, ∫ (x : α), (φ i).indicator f x ∂μ) l (𝓝 (∫ (x : α), f x ∂μ)),
by { convert h, ext n, rw integral_indicator (hφ.measurable n) },
tendsto_integral_filter_of_dominated_convergence (λ x, ∥f x∥)
(eventually_of_forall $ λ i, hfi.ae_measurable.indicator $ hφ.measurable i)
(eventually_of_forall $ λ i, ae_of_all _ $ λ x, norm_indicator_le_norm_self _ _)
hfi.norm (hφ.ae_tendsto_indicator f)
/-- Slight reformulation of
`measure_theory.ae_cover.integral_tendsto_of_countably_generated`. -/
lemma ae_cover.integral_eq_of_tendsto [l.ne_bot] [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → E}
(I : E) (hfi : integrable f μ)
(h : tendsto (λ n, ∫ x in φ n, f x ∂μ) l (𝓝 I)) :
∫ x, f x ∂μ = I :=
tendsto_nhds_unique (hφ.integral_tendsto_of_countably_generated hfi) h
lemma ae_cover.integral_eq_of_tendsto_of_nonneg_ae [l.ne_bot] [l.is_countably_generated]
{φ : ι → set α} (hφ : ae_cover μ l φ) {f : α → ℝ} (I : ℝ)
(hnng : 0 ≤ᵐ[μ] f) (hfi : ∀ n, integrable_on f (φ n) μ)
(htendsto : tendsto (λ n, ∫ x in φ n, f x ∂μ) l (𝓝 I)) :
∫ x, f x ∂μ = I :=
have hfi' : integrable f μ,
from hφ.integrable_of_integral_tendsto_of_nonneg_ae I hfi hnng htendsto,
hφ.integral_eq_of_tendsto I hfi' htendsto
end integral
section integrable_of_interval_integral
variables {α ι E : Type*}
[topological_space α] [linear_order α] [order_closed_topology α]
[measurable_space α] [opens_measurable_space α] {μ : measure α}
{l : filter ι} [filter.ne_bot l] [is_countably_generated l]
[measurable_space E] [normed_group E] [borel_space E]
{a b : ι → α} {f : α → E}
lemma integrable_of_interval_integral_norm_bounded [no_min_order α] [nonempty α]
(I : ℝ) (hfi : ∀ i, integrable_on f (Ioc (a i) (b i)) μ)
(ha : tendsto a l at_bot) (hb : tendsto b l at_top)
(h : ∀ᶠ i in l, ∫ x in a i .. b i, ∥f x∥ ∂μ ≤ I) :
integrable f μ :=
begin
let c : α := classical.choice ‹_›,
have hφ : ae_cover μ l _ := ae_cover_Ioc ha hb,
refine hφ.integrable_of_integral_norm_bounded I hfi (h.mp _),
filter_upwards [ha.eventually (eventually_le_at_bot c), hb.eventually (eventually_ge_at_top c)]
with i hai hbi ht,
rwa ←interval_integral.integral_of_le (hai.trans hbi)
end
lemma integrable_of_interval_integral_norm_tendsto [no_min_order α] [nonempty α]
(I : ℝ) (hfi : ∀ i, integrable_on f (Ioc (a i) (b i)) μ)
(ha : tendsto a l at_bot) (hb : tendsto b l at_top)
(h : tendsto (λ i, ∫ x in a i .. b i, ∥f x∥ ∂μ) l (𝓝 I)) :
integrable f μ :=
let ⟨I', hI'⟩ := h.is_bounded_under_le in
integrable_of_interval_integral_norm_bounded I' hfi ha hb hI'
lemma integrable_on_Iic_of_interval_integral_norm_bounded [no_min_order α] (I : ℝ) (b : α)
(hfi : ∀ i, integrable_on f (Ioc (a i) b) μ) (ha : tendsto a l at_bot)
(h : ∀ᶠ i in l, (∫ x in a i .. b, ∥f x∥ ∂μ) ≤ I) :
integrable_on f (Iic b) μ :=
begin
have hφ : ae_cover (μ.restrict $ Iic b) l _ := ae_cover_Ioi ha,
have hfi : ∀ i, integrable_on f (Ioi (a i)) (μ.restrict $ Iic b),
{ intro i,
rw [integrable_on, measure.restrict_restrict (hφ.measurable i)],
exact hfi i },
refine hφ.integrable_of_integral_norm_bounded I hfi (h.mp _),
filter_upwards [ha.eventually (eventually_le_at_bot b)] with i hai,
rw [interval_integral.integral_of_le hai, measure.restrict_restrict (hφ.measurable i)],
exact id
end
lemma integrable_on_Iic_of_interval_integral_norm_tendsto [no_min_order α] (I : ℝ) (b : α)
(hfi : ∀ i, integrable_on f (Ioc (a i) b) μ) (ha : tendsto a l at_bot)
(h : tendsto (λ i, ∫ x in a i .. b, ∥f x∥ ∂μ) l (𝓝 I)) :
integrable_on f (Iic b) μ :=
let ⟨I', hI'⟩ := h.is_bounded_under_le in
integrable_on_Iic_of_interval_integral_norm_bounded I' b hfi ha hI'
lemma integrable_on_Ioi_of_interval_integral_norm_bounded (I : ℝ) (a : α)
(hfi : ∀ i, integrable_on f (Ioc a (b i)) μ) (hb : tendsto b l at_top)
(h : ∀ᶠ i in l, (∫ x in a .. b i, ∥f x∥ ∂μ) ≤ I) :
integrable_on f (Ioi a) μ :=
begin
have hφ : ae_cover (μ.restrict $ Ioi a) l _ := ae_cover_Iic hb,
have hfi : ∀ i, integrable_on f (Iic (b i)) (μ.restrict $ Ioi a),
{ intro i,
rw [integrable_on, measure.restrict_restrict (hφ.measurable i), inter_comm],
exact hfi i },
refine hφ.integrable_of_integral_norm_bounded I hfi (h.mp _),
filter_upwards [hb.eventually (eventually_ge_at_top a)] with i hbi,
rw [interval_integral.integral_of_le hbi, measure.restrict_restrict (hφ.measurable i),
inter_comm],
exact id
end
lemma integrable_on_Ioi_of_interval_integral_norm_tendsto (I : ℝ) (a : α)
(hfi : ∀ i, integrable_on f (Ioc a (b i)) μ) (hb : tendsto b l at_top)
(h : tendsto (λ i, ∫ x in a .. b i, ∥f x∥ ∂μ) l (𝓝 $ I)) :
integrable_on f (Ioi a) μ :=
let ⟨I', hI'⟩ := h.is_bounded_under_le in
integrable_on_Ioi_of_interval_integral_norm_bounded I' a hfi hb hI'
end integrable_of_interval_integral
section integral_of_interval_integral
variables {α ι E : Type*}
[topological_space α] [linear_order α] [order_closed_topology α]
[measurable_space α] [opens_measurable_space α] {μ : measure α}
{l : filter ι} [is_countably_generated l]
[measurable_space E] [normed_group E] [normed_space ℝ E] [borel_space E]
[complete_space E] [second_countable_topology E]
{a b : ι → α} {f : α → E}
lemma interval_integral_tendsto_integral [no_min_order α] [nonempty α]
(hfi : integrable f μ) (ha : tendsto a l at_bot) (hb : tendsto b l at_top) :
tendsto (λ i, ∫ x in a i .. b i, f x ∂μ) l (𝓝 $ ∫ x, f x ∂μ) :=
begin
let φ := λ i, Ioc (a i) (b i),
let c : α := classical.choice ‹_›,
have hφ : ae_cover μ l φ := ae_cover_Ioc ha hb,
refine (hφ.integral_tendsto_of_countably_generated hfi).congr' _,
filter_upwards [ha.eventually (eventually_le_at_bot c), hb.eventually (eventually_ge_at_top c)]
with i hai hbi,
exact (interval_integral.integral_of_le (hai.trans hbi)).symm
end
lemma interval_integral_tendsto_integral_Iic [no_min_order α] (b : α)
(hfi : integrable_on f (Iic b) μ) (ha : tendsto a l at_bot) :
tendsto (λ i, ∫ x in a i .. b, f x ∂μ) l (𝓝 $ ∫ x in Iic b, f x ∂μ) :=
begin
let φ := λ i, Ioi (a i),
have hφ : ae_cover (μ.restrict $ Iic b) l φ := ae_cover_Ioi ha,
refine (hφ.integral_tendsto_of_countably_generated hfi).congr' _,
filter_upwards [ha.eventually (eventually_le_at_bot $ b)] with i hai,
rw [interval_integral.integral_of_le hai, measure.restrict_restrict (hφ.measurable i)],
refl,
end
lemma interval_integral_tendsto_integral_Ioi (a : α)
(hfi : integrable_on f (Ioi a) μ) (hb : tendsto b l at_top) :
tendsto (λ i, ∫ x in a .. b i, f x ∂μ) l (𝓝 $ ∫ x in Ioi a, f x ∂μ) :=
begin
let φ := λ i, Iic (b i),
have hφ : ae_cover (μ.restrict $ Ioi a) l φ := ae_cover_Iic hb,
refine (hφ.integral_tendsto_of_countably_generated hfi).congr' _,
filter_upwards [hb.eventually (eventually_ge_at_top $ a)] with i hbi,
rw [interval_integral.integral_of_le hbi, measure.restrict_restrict (hφ.measurable i),
inter_comm],
refl,
end
end integral_of_interval_integral
end measure_theory
|
[GOAL]
𝕜 : Type u_1
inst✝⁷ : CommRing 𝕜
V : Type u_2
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module 𝕜 V
inst✝⁴ : MeasurableSpace V
W : Type u_3
inst✝³ : AddCommGroup W
inst✝² : Module 𝕜 W
E : Type u_4
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
r : ℂ
⊢ fourierIntegral e μ L (r • f) = r • fourierIntegral e μ L f
[PROOFSTEP]
ext1 w
[GOAL]
case h
𝕜 : Type u_1
inst✝⁷ : CommRing 𝕜
V : Type u_2
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module 𝕜 V
inst✝⁴ : MeasurableSpace V
W : Type u_3
inst✝³ : AddCommGroup W
inst✝² : Module 𝕜 W
E : Type u_4
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
r : ℂ
w : W
⊢ fourierIntegral e μ L (r • f) w = (r • fourierIntegral e μ L f) w
[PROOFSTEP]
simp only [Pi.smul_apply, fourierIntegral, ← integral_smul]
[GOAL]
case h
𝕜 : Type u_1
inst✝⁷ : CommRing 𝕜
V : Type u_2
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module 𝕜 V
inst✝⁴ : MeasurableSpace V
W : Type u_3
inst✝³ : AddCommGroup W
inst✝² : Module 𝕜 W
E : Type u_4
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
r : ℂ
w : W
⊢ ∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • r • f v ∂μ =
∫ (a : V), r • ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L a) w))) • f a ∂μ
[PROOFSTEP]
congr
[GOAL]
case h.e_f
𝕜 : Type u_1
inst✝⁷ : CommRing 𝕜
V : Type u_2
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module 𝕜 V
inst✝⁴ : MeasurableSpace V
W : Type u_3
inst✝³ : AddCommGroup W
inst✝² : Module 𝕜 W
E : Type u_4
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
r : ℂ
w : W
⊢ (fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • r • f v) = fun a =>
r • ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L a) w))) • f a
[PROOFSTEP]
funext
[GOAL]
case h.e_f.h
𝕜 : Type u_1
inst✝⁷ : CommRing 𝕜
V : Type u_2
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module 𝕜 V
inst✝⁴ : MeasurableSpace V
W : Type u_3
inst✝³ : AddCommGroup W
inst✝² : Module 𝕜 W
E : Type u_4
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
r : ℂ
w : W
x✝ : V
⊢ ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L x✝) w))) • r • f x✝ = r • ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L x✝) w))) • f x✝
[PROOFSTEP]
rw [smul_comm]
[GOAL]
𝕜 : Type u_1
inst✝⁷ : CommRing 𝕜
V : Type u_2
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module 𝕜 V
inst✝⁴ : MeasurableSpace V
W : Type u_3
inst✝³ : AddCommGroup W
inst✝² : Module 𝕜 W
E : Type u_4
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
w : W
⊢ ‖fourierIntegral e μ L f w‖ ≤ ∫ (v : V), ‖f v‖ ∂μ
[PROOFSTEP]
refine' (norm_integral_le_integral_norm _).trans (le_of_eq _)
[GOAL]
𝕜 : Type u_1
inst✝⁷ : CommRing 𝕜
V : Type u_2
inst✝⁶ : AddCommGroup V
inst✝⁵ : Module 𝕜 V
inst✝⁴ : MeasurableSpace V
W : Type u_3
inst✝³ : AddCommGroup W
inst✝² : Module 𝕜 W
E : Type u_4
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
w : W
⊢ ∫ (a : V), ‖↑(↑e (↑Multiplicative.ofAdd (-↑(↑L a) w))) • f a‖ ∂μ = ∫ (v : V), ‖f v‖ ∂μ
[PROOFSTEP]
simp_rw [norm_smul, Complex.norm_eq_abs, abs_coe_circle, one_mul]
[GOAL]
𝕜 : Type u_1
inst✝⁹ : CommRing 𝕜
V : Type u_2
inst✝⁸ : AddCommGroup V
inst✝⁷ : Module 𝕜 V
inst✝⁶ : MeasurableSpace V
W : Type u_3
inst✝⁵ : AddCommGroup W
inst✝⁴ : Module 𝕜 W
E : Type u_4
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
inst✝¹ : MeasurableAdd V
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
inst✝ : Measure.IsAddRightInvariant μ
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
v₀ : V
⊢ fourierIntegral e μ L (f ∘ fun v => v + v₀) = fun w =>
↑(↑e (↑Multiplicative.ofAdd (↑(↑L v₀) w))) • fourierIntegral e μ L f w
[PROOFSTEP]
ext1 w
[GOAL]
case h
𝕜 : Type u_1
inst✝⁹ : CommRing 𝕜
V : Type u_2
inst✝⁸ : AddCommGroup V
inst✝⁷ : Module 𝕜 V
inst✝⁶ : MeasurableSpace V
W : Type u_3
inst✝⁵ : AddCommGroup W
inst✝⁴ : Module 𝕜 W
E : Type u_4
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
inst✝¹ : MeasurableAdd V
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
inst✝ : Measure.IsAddRightInvariant μ
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
v₀ : V
w : W
⊢ fourierIntegral e μ L (f ∘ fun v => v + v₀) w = ↑(↑e (↑Multiplicative.ofAdd (↑(↑L v₀) w))) • fourierIntegral e μ L f w
[PROOFSTEP]
dsimp only [fourierIntegral, Function.comp_apply]
[GOAL]
case h
𝕜 : Type u_1
inst✝⁹ : CommRing 𝕜
V : Type u_2
inst✝⁸ : AddCommGroup V
inst✝⁷ : Module 𝕜 V
inst✝⁶ : MeasurableSpace V
W : Type u_3
inst✝⁵ : AddCommGroup W
inst✝⁴ : Module 𝕜 W
E : Type u_4
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
inst✝¹ : MeasurableAdd V
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
inst✝ : Measure.IsAddRightInvariant μ
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
v₀ : V
w : W
⊢ ∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f (v + v₀) ∂μ =
↑(↑e (↑Multiplicative.ofAdd (↑(↑L v₀) w))) • ∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v ∂μ
[PROOFSTEP]
conv in L _ => rw [← add_sub_cancel v v₀]
[GOAL]
𝕜 : Type u_1
inst✝⁹ : CommRing 𝕜
V : Type u_2
inst✝⁸ : AddCommGroup V
inst✝⁷ : Module 𝕜 V
inst✝⁶ : MeasurableSpace V
W : Type u_3
inst✝⁵ : AddCommGroup W
inst✝⁴ : Module 𝕜 W
E : Type u_4
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
inst✝¹ : MeasurableAdd V
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
inst✝ : Measure.IsAddRightInvariant μ
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
v₀ : V
w : W
v : V
| ↑L v
[PROOFSTEP]
rw [← add_sub_cancel v v₀]
[GOAL]
𝕜 : Type u_1
inst✝⁹ : CommRing 𝕜
V : Type u_2
inst✝⁸ : AddCommGroup V
inst✝⁷ : Module 𝕜 V
inst✝⁶ : MeasurableSpace V
W : Type u_3
inst✝⁵ : AddCommGroup W
inst✝⁴ : Module 𝕜 W
E : Type u_4
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
inst✝¹ : MeasurableAdd V
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
inst✝ : Measure.IsAddRightInvariant μ
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
v₀ : V
w : W
v : V
| ↑L v
[PROOFSTEP]
rw [← add_sub_cancel v v₀]
[GOAL]
𝕜 : Type u_1
inst✝⁹ : CommRing 𝕜
V : Type u_2
inst✝⁸ : AddCommGroup V
inst✝⁷ : Module 𝕜 V
inst✝⁶ : MeasurableSpace V
W : Type u_3
inst✝⁵ : AddCommGroup W
inst✝⁴ : Module 𝕜 W
E : Type u_4
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
inst✝¹ : MeasurableAdd V
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
inst✝ : Measure.IsAddRightInvariant μ
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
v₀ : V
w : W
v : V
| ↑L v
[PROOFSTEP]
rw [← add_sub_cancel v v₀]
[GOAL]
case h
𝕜 : Type u_1
inst✝⁹ : CommRing 𝕜
V : Type u_2
inst✝⁸ : AddCommGroup V
inst✝⁷ : Module 𝕜 V
inst✝⁶ : MeasurableSpace V
W : Type u_3
inst✝⁵ : AddCommGroup W
inst✝⁴ : Module 𝕜 W
E : Type u_4
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
inst✝¹ : MeasurableAdd V
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
inst✝ : Measure.IsAddRightInvariant μ
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
v₀ : V
w : W
⊢ ∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L (v + v₀ - v₀)) w))) • f (v + v₀) ∂μ =
↑(↑e (↑Multiplicative.ofAdd (↑(↑L v₀) w))) • ∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v ∂μ
[PROOFSTEP]
rw [integral_add_right_eq_self fun v : V => e[-L (v - v₀) w] • f v]
[GOAL]
case h
𝕜 : Type u_1
inst✝⁹ : CommRing 𝕜
V : Type u_2
inst✝⁸ : AddCommGroup V
inst✝⁷ : Module 𝕜 V
inst✝⁶ : MeasurableSpace V
W : Type u_3
inst✝⁵ : AddCommGroup W
inst✝⁴ : Module 𝕜 W
E : Type u_4
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
inst✝¹ : MeasurableAdd V
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
inst✝ : Measure.IsAddRightInvariant μ
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
v₀ : V
w : W
⊢ ∫ (x : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L (x - v₀)) w))) • f x ∂μ =
↑(↑e (↑Multiplicative.ofAdd (↑(↑L v₀) w))) • ∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v ∂μ
[PROOFSTEP]
dsimp only
[GOAL]
case h
𝕜 : Type u_1
inst✝⁹ : CommRing 𝕜
V : Type u_2
inst✝⁸ : AddCommGroup V
inst✝⁷ : Module 𝕜 V
inst✝⁶ : MeasurableSpace V
W : Type u_3
inst✝⁵ : AddCommGroup W
inst✝⁴ : Module 𝕜 W
E : Type u_4
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
inst✝¹ : MeasurableAdd V
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
inst✝ : Measure.IsAddRightInvariant μ
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
v₀ : V
w : W
⊢ ∫ (x : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L (x - v₀)) w))) • f x ∂μ =
↑(↑e (↑Multiplicative.ofAdd (↑(↑L v₀) w))) • ∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v ∂μ
[PROOFSTEP]
rw [← integral_smul]
[GOAL]
case h
𝕜 : Type u_1
inst✝⁹ : CommRing 𝕜
V : Type u_2
inst✝⁸ : AddCommGroup V
inst✝⁷ : Module 𝕜 V
inst✝⁶ : MeasurableSpace V
W : Type u_3
inst✝⁵ : AddCommGroup W
inst✝⁴ : Module 𝕜 W
E : Type u_4
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
inst✝¹ : MeasurableAdd V
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
inst✝ : Measure.IsAddRightInvariant μ
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
v₀ : V
w : W
⊢ ∫ (x : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L (x - v₀)) w))) • f x ∂μ =
∫ (a : V), ↑(↑e (↑Multiplicative.ofAdd (↑(↑L v₀) w))) • ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L a) w))) • f a ∂μ
[PROOFSTEP]
congr 1 with v
[GOAL]
case h.e_f.h
𝕜 : Type u_1
inst✝⁹ : CommRing 𝕜
V : Type u_2
inst✝⁸ : AddCommGroup V
inst✝⁷ : Module 𝕜 V
inst✝⁶ : MeasurableSpace V
W : Type u_3
inst✝⁵ : AddCommGroup W
inst✝⁴ : Module 𝕜 W
E : Type u_4
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℂ E
inst✝¹ : MeasurableAdd V
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
inst✝ : Measure.IsAddRightInvariant μ
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
f : V → E
v₀ : V
w : W
v : V
⊢ ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L (v - v₀)) w))) • f v =
↑(↑e (↑Multiplicative.ofAdd (↑(↑L v₀) w))) • ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v
[PROOFSTEP]
rw [← smul_assoc, smul_eq_mul, ← Submonoid.coe_mul, ← e.map_mul, ← ofAdd_add, ← LinearMap.neg_apply, ← sub_eq_add_neg, ←
LinearMap.sub_apply, LinearMap.map_sub, neg_sub]
[GOAL]
𝕜 : Type u_1
inst✝¹² : CommRing 𝕜
V : Type u_2
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module 𝕜 V
inst✝⁹ : MeasurableSpace V
W : Type u_3
inst✝⁸ : AddCommGroup W
inst✝⁷ : Module 𝕜 W
E : Type u_4
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
inst✝⁴ : TopologicalSpace 𝕜
inst✝³ : TopologicalRing 𝕜
inst✝² : TopologicalSpace V
inst✝¹ : BorelSpace V
inst✝ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
w : W
⊢ Integrable f ↔ Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v
[PROOFSTEP]
have aux : ∀ {g : V → E} (_ : Integrable g μ) (x : W), Integrable (fun v : V => e[-L v x] • g v) μ :=
by
intro g hg x
have c : Continuous fun v => e[-L v x] :=
by
refine' (continuous_induced_rng.mp he).comp (continuous_ofAdd.comp (Continuous.neg _))
exact hL.comp (continuous_prod_mk.mpr ⟨continuous_id, continuous_const⟩)
rw [← integrable_norm_iff (c.aestronglyMeasurable.smul hg.1)]
convert hg.norm using 2
rw [norm_smul, Complex.norm_eq_abs, abs_coe_circle, one_mul]
-- then use it for both directions
[GOAL]
𝕜 : Type u_1
inst✝¹² : CommRing 𝕜
V : Type u_2
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module 𝕜 V
inst✝⁹ : MeasurableSpace V
W : Type u_3
inst✝⁸ : AddCommGroup W
inst✝⁷ : Module 𝕜 W
E : Type u_4
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
inst✝⁴ : TopologicalSpace 𝕜
inst✝³ : TopologicalRing 𝕜
inst✝² : TopologicalSpace V
inst✝¹ : BorelSpace V
inst✝ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
w : W
⊢ ∀ {g : V → E}, Integrable g → ∀ (x : W), Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) x))) • g v
[PROOFSTEP]
intro g hg x
[GOAL]
𝕜 : Type u_1
inst✝¹² : CommRing 𝕜
V : Type u_2
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module 𝕜 V
inst✝⁹ : MeasurableSpace V
W : Type u_3
inst✝⁸ : AddCommGroup W
inst✝⁷ : Module 𝕜 W
E : Type u_4
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
inst✝⁴ : TopologicalSpace 𝕜
inst✝³ : TopologicalRing 𝕜
inst✝² : TopologicalSpace V
inst✝¹ : BorelSpace V
inst✝ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
w : W
g : V → E
hg : Integrable g
x : W
⊢ Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) x))) • g v
[PROOFSTEP]
have c : Continuous fun v => e[-L v x] :=
by
refine' (continuous_induced_rng.mp he).comp (continuous_ofAdd.comp (Continuous.neg _))
exact hL.comp (continuous_prod_mk.mpr ⟨continuous_id, continuous_const⟩)
[GOAL]
𝕜 : Type u_1
inst✝¹² : CommRing 𝕜
V : Type u_2
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module 𝕜 V
inst✝⁹ : MeasurableSpace V
W : Type u_3
inst✝⁸ : AddCommGroup W
inst✝⁷ : Module 𝕜 W
E : Type u_4
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
inst✝⁴ : TopologicalSpace 𝕜
inst✝³ : TopologicalRing 𝕜
inst✝² : TopologicalSpace V
inst✝¹ : BorelSpace V
inst✝ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
w : W
g : V → E
hg : Integrable g
x : W
⊢ Continuous fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) x)))
[PROOFSTEP]
refine' (continuous_induced_rng.mp he).comp (continuous_ofAdd.comp (Continuous.neg _))
[GOAL]
𝕜 : Type u_1
inst✝¹² : CommRing 𝕜
V : Type u_2
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module 𝕜 V
inst✝⁹ : MeasurableSpace V
W : Type u_3
inst✝⁸ : AddCommGroup W
inst✝⁷ : Module 𝕜 W
E : Type u_4
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
inst✝⁴ : TopologicalSpace 𝕜
inst✝³ : TopologicalRing 𝕜
inst✝² : TopologicalSpace V
inst✝¹ : BorelSpace V
inst✝ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
w : W
g : V → E
hg : Integrable g
x : W
⊢ Continuous fun v => ↑(↑L v) x
[PROOFSTEP]
exact hL.comp (continuous_prod_mk.mpr ⟨continuous_id, continuous_const⟩)
[GOAL]
𝕜 : Type u_1
inst✝¹² : CommRing 𝕜
V : Type u_2
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module 𝕜 V
inst✝⁹ : MeasurableSpace V
W : Type u_3
inst✝⁸ : AddCommGroup W
inst✝⁷ : Module 𝕜 W
E : Type u_4
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
inst✝⁴ : TopologicalSpace 𝕜
inst✝³ : TopologicalRing 𝕜
inst✝² : TopologicalSpace V
inst✝¹ : BorelSpace V
inst✝ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
w : W
g : V → E
hg : Integrable g
x : W
c : Continuous fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) x)))
⊢ Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) x))) • g v
[PROOFSTEP]
rw [← integrable_norm_iff (c.aestronglyMeasurable.smul hg.1)]
[GOAL]
𝕜 : Type u_1
inst✝¹² : CommRing 𝕜
V : Type u_2
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module 𝕜 V
inst✝⁹ : MeasurableSpace V
W : Type u_3
inst✝⁸ : AddCommGroup W
inst✝⁷ : Module 𝕜 W
E : Type u_4
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
inst✝⁴ : TopologicalSpace 𝕜
inst✝³ : TopologicalRing 𝕜
inst✝² : TopologicalSpace V
inst✝¹ : BorelSpace V
inst✝ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
w : W
g : V → E
hg : Integrable g
x : W
c : Continuous fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) x)))
⊢ Integrable fun a => ‖↑(↑e (↑Multiplicative.ofAdd (-↑(↑L a) x))) • g a‖
[PROOFSTEP]
convert hg.norm using 2
[GOAL]
case h.e'_5.h
𝕜 : Type u_1
inst✝¹² : CommRing 𝕜
V : Type u_2
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module 𝕜 V
inst✝⁹ : MeasurableSpace V
W : Type u_3
inst✝⁸ : AddCommGroup W
inst✝⁷ : Module 𝕜 W
E : Type u_4
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
inst✝⁴ : TopologicalSpace 𝕜
inst✝³ : TopologicalRing 𝕜
inst✝² : TopologicalSpace V
inst✝¹ : BorelSpace V
inst✝ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
w : W
g : V → E
hg : Integrable g
x : W
c : Continuous fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) x)))
x✝ : V
⊢ ‖↑(↑e (↑Multiplicative.ofAdd (-↑(↑L x✝) x))) • g x✝‖ = ‖g x✝‖
[PROOFSTEP]
rw [norm_smul, Complex.norm_eq_abs, abs_coe_circle, one_mul]
-- then use it for both directions
[GOAL]
𝕜 : Type u_1
inst✝¹² : CommRing 𝕜
V : Type u_2
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module 𝕜 V
inst✝⁹ : MeasurableSpace V
W : Type u_3
inst✝⁸ : AddCommGroup W
inst✝⁷ : Module 𝕜 W
E : Type u_4
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
inst✝⁴ : TopologicalSpace 𝕜
inst✝³ : TopologicalRing 𝕜
inst✝² : TopologicalSpace V
inst✝¹ : BorelSpace V
inst✝ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
w : W
aux : ∀ {g : V → E}, Integrable g → ∀ (x : W), Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) x))) • g v
⊢ Integrable f ↔ Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v
[PROOFSTEP]
refine' ⟨fun hf => aux hf w, fun hf => _⟩
[GOAL]
𝕜 : Type u_1
inst✝¹² : CommRing 𝕜
V : Type u_2
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module 𝕜 V
inst✝⁹ : MeasurableSpace V
W : Type u_3
inst✝⁸ : AddCommGroup W
inst✝⁷ : Module 𝕜 W
E : Type u_4
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
inst✝⁴ : TopologicalSpace 𝕜
inst✝³ : TopologicalRing 𝕜
inst✝² : TopologicalSpace V
inst✝¹ : BorelSpace V
inst✝ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
w : W
aux : ∀ {g : V → E}, Integrable g → ∀ (x : W), Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) x))) • g v
hf : Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v
⊢ Integrable f
[PROOFSTEP]
convert aux hf (-w)
[GOAL]
case h.e'_5.h
𝕜 : Type u_1
inst✝¹² : CommRing 𝕜
V : Type u_2
inst✝¹¹ : AddCommGroup V
inst✝¹⁰ : Module 𝕜 V
inst✝⁹ : MeasurableSpace V
W : Type u_3
inst✝⁸ : AddCommGroup W
inst✝⁷ : Module 𝕜 W
E : Type u_4
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
inst✝⁴ : TopologicalSpace 𝕜
inst✝³ : TopologicalRing 𝕜
inst✝² : TopologicalSpace V
inst✝¹ : BorelSpace V
inst✝ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
w : W
aux : ∀ {g : V → E}, Integrable g → ∀ (x : W), Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) x))) • g v
hf : Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v
x✝ : V
⊢ f x✝ = ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L x✝) (-w)))) • ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L x✝) w))) • f x✝
[PROOFSTEP]
rw [← smul_assoc, smul_eq_mul, ← Submonoid.coe_mul, ← MonoidHom.map_mul, ← ofAdd_add, LinearMap.map_neg, neg_neg, ←
sub_eq_add_neg, sub_self, ofAdd_zero, MonoidHom.map_one, Submonoid.coe_one, one_smul]
[GOAL]
𝕜 : Type u_1
inst✝¹³ : CommRing 𝕜
V : Type u_2
inst✝¹² : AddCommGroup V
inst✝¹¹ : Module 𝕜 V
inst✝¹⁰ : MeasurableSpace V
W : Type u_3
inst✝⁹ : AddCommGroup W
inst✝⁸ : Module 𝕜 W
E : Type u_4
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℂ E
inst✝⁵ : TopologicalSpace 𝕜
inst✝⁴ : TopologicalRing 𝕜
inst✝³ : TopologicalSpace V
inst✝² : BorelSpace V
inst✝¹ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝ : CompleteSpace E
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f g : V → E
hf : Integrable f
hg : Integrable g
⊢ fourierIntegral e μ L f + fourierIntegral e μ L g = fourierIntegral e μ L (f + g)
[PROOFSTEP]
ext1 w
[GOAL]
case h
𝕜 : Type u_1
inst✝¹³ : CommRing 𝕜
V : Type u_2
inst✝¹² : AddCommGroup V
inst✝¹¹ : Module 𝕜 V
inst✝¹⁰ : MeasurableSpace V
W : Type u_3
inst✝⁹ : AddCommGroup W
inst✝⁸ : Module 𝕜 W
E : Type u_4
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℂ E
inst✝⁵ : TopologicalSpace 𝕜
inst✝⁴ : TopologicalRing 𝕜
inst✝³ : TopologicalSpace V
inst✝² : BorelSpace V
inst✝¹ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝ : CompleteSpace E
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f g : V → E
hf : Integrable f
hg : Integrable g
w : W
⊢ (fourierIntegral e μ L f + fourierIntegral e μ L g) w = fourierIntegral e μ L (f + g) w
[PROOFSTEP]
dsimp only [Pi.add_apply, fourierIntegral]
[GOAL]
case h
𝕜 : Type u_1
inst✝¹³ : CommRing 𝕜
V : Type u_2
inst✝¹² : AddCommGroup V
inst✝¹¹ : Module 𝕜 V
inst✝¹⁰ : MeasurableSpace V
W : Type u_3
inst✝⁹ : AddCommGroup W
inst✝⁸ : Module 𝕜 W
E : Type u_4
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℂ E
inst✝⁵ : TopologicalSpace 𝕜
inst✝⁴ : TopologicalRing 𝕜
inst✝³ : TopologicalSpace V
inst✝² : BorelSpace V
inst✝¹ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝ : CompleteSpace E
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f g : V → E
hf : Integrable f
hg : Integrable g
w : W
⊢ ∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v ∂μ +
∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • g v ∂μ =
∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • (f v + g v) ∂μ
[PROOFSTEP]
simp_rw [smul_add]
[GOAL]
case h
𝕜 : Type u_1
inst✝¹³ : CommRing 𝕜
V : Type u_2
inst✝¹² : AddCommGroup V
inst✝¹¹ : Module 𝕜 V
inst✝¹⁰ : MeasurableSpace V
W : Type u_3
inst✝⁹ : AddCommGroup W
inst✝⁸ : Module 𝕜 W
E : Type u_4
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℂ E
inst✝⁵ : TopologicalSpace 𝕜
inst✝⁴ : TopologicalRing 𝕜
inst✝³ : TopologicalSpace V
inst✝² : BorelSpace V
inst✝¹ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝ : CompleteSpace E
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f g : V → E
hf : Integrable f
hg : Integrable g
w : W
⊢ ∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v ∂μ +
∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • g v ∂μ =
∫ (v : V), ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v + ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • g v ∂μ
[PROOFSTEP]
rw [integral_add]
[GOAL]
case h.hf
𝕜 : Type u_1
inst✝¹³ : CommRing 𝕜
V : Type u_2
inst✝¹² : AddCommGroup V
inst✝¹¹ : Module 𝕜 V
inst✝¹⁰ : MeasurableSpace V
W : Type u_3
inst✝⁹ : AddCommGroup W
inst✝⁸ : Module 𝕜 W
E : Type u_4
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℂ E
inst✝⁵ : TopologicalSpace 𝕜
inst✝⁴ : TopologicalRing 𝕜
inst✝³ : TopologicalSpace V
inst✝² : BorelSpace V
inst✝¹ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝ : CompleteSpace E
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f g : V → E
hf : Integrable f
hg : Integrable g
w : W
⊢ Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v
[PROOFSTEP]
exact (fourier_integral_convergent_iff he hL w).mp hf
[GOAL]
case h.hg
𝕜 : Type u_1
inst✝¹³ : CommRing 𝕜
V : Type u_2
inst✝¹² : AddCommGroup V
inst✝¹¹ : Module 𝕜 V
inst✝¹⁰ : MeasurableSpace V
W : Type u_3
inst✝⁹ : AddCommGroup W
inst✝⁸ : Module 𝕜 W
E : Type u_4
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℂ E
inst✝⁵ : TopologicalSpace 𝕜
inst✝⁴ : TopologicalRing 𝕜
inst✝³ : TopologicalSpace V
inst✝² : BorelSpace V
inst✝¹ : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝ : CompleteSpace E
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f g : V → E
hf : Integrable f
hg : Integrable g
w : W
⊢ Integrable fun v => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • g v
[PROOFSTEP]
exact (fourier_integral_convergent_iff he hL w).mp hg
[GOAL]
𝕜 : Type u_1
inst✝¹⁴ : CommRing 𝕜
V : Type u_2
inst✝¹³ : AddCommGroup V
inst✝¹² : Module 𝕜 V
inst✝¹¹ : MeasurableSpace V
W : Type u_3
inst✝¹⁰ : AddCommGroup W
inst✝⁹ : Module 𝕜 W
E : Type u_4
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace ℂ E
inst✝⁶ : TopologicalSpace 𝕜
inst✝⁵ : TopologicalRing 𝕜
inst✝⁴ : TopologicalSpace V
inst✝³ : BorelSpace V
inst✝² : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝¹ : CompleteSpace E
inst✝ : TopologicalSpace.FirstCountableTopology W
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
hf : Integrable f
⊢ Continuous (fourierIntegral e μ L f)
[PROOFSTEP]
apply continuous_of_dominated
[GOAL]
case hF_meas
𝕜 : Type u_1
inst✝¹⁴ : CommRing 𝕜
V : Type u_2
inst✝¹³ : AddCommGroup V
inst✝¹² : Module 𝕜 V
inst✝¹¹ : MeasurableSpace V
W : Type u_3
inst✝¹⁰ : AddCommGroup W
inst✝⁹ : Module 𝕜 W
E : Type u_4
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace ℂ E
inst✝⁶ : TopologicalSpace 𝕜
inst✝⁵ : TopologicalRing 𝕜
inst✝⁴ : TopologicalSpace V
inst✝³ : BorelSpace V
inst✝² : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝¹ : CompleteSpace E
inst✝ : TopologicalSpace.FirstCountableTopology W
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
hf : Integrable f
⊢ ∀ (x : W), AEStronglyMeasurable (fun a => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L a) x))) • f a) μ
[PROOFSTEP]
exact fun w => ((fourier_integral_convergent_iff he hL w).mp hf).1
[GOAL]
case h_bound
𝕜 : Type u_1
inst✝¹⁴ : CommRing 𝕜
V : Type u_2
inst✝¹³ : AddCommGroup V
inst✝¹² : Module 𝕜 V
inst✝¹¹ : MeasurableSpace V
W : Type u_3
inst✝¹⁰ : AddCommGroup W
inst✝⁹ : Module 𝕜 W
E : Type u_4
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace ℂ E
inst✝⁶ : TopologicalSpace 𝕜
inst✝⁵ : TopologicalRing 𝕜
inst✝⁴ : TopologicalSpace V
inst✝³ : BorelSpace V
inst✝² : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝¹ : CompleteSpace E
inst✝ : TopologicalSpace.FirstCountableTopology W
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
hf : Integrable f
⊢ ∀ (x : W), ∀ᵐ (a : V) ∂μ, ‖↑(↑e (↑Multiplicative.ofAdd (-↑(↑L a) x))) • f a‖ ≤ ?bound a
[PROOFSTEP]
refine' fun w => ae_of_all _ fun v => _
[GOAL]
case bound
𝕜 : Type u_1
inst✝¹⁴ : CommRing 𝕜
V : Type u_2
inst✝¹³ : AddCommGroup V
inst✝¹² : Module 𝕜 V
inst✝¹¹ : MeasurableSpace V
W : Type u_3
inst✝¹⁰ : AddCommGroup W
inst✝⁹ : Module 𝕜 W
E : Type u_4
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace ℂ E
inst✝⁶ : TopologicalSpace 𝕜
inst✝⁵ : TopologicalRing 𝕜
inst✝⁴ : TopologicalSpace V
inst✝³ : BorelSpace V
inst✝² : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝¹ : CompleteSpace E
inst✝ : TopologicalSpace.FirstCountableTopology W
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
hf : Integrable f
⊢ V → ℝ
[PROOFSTEP]
exact fun v => ‖f v‖
[GOAL]
case h_bound
𝕜 : Type u_1
inst✝¹⁴ : CommRing 𝕜
V : Type u_2
inst✝¹³ : AddCommGroup V
inst✝¹² : Module 𝕜 V
inst✝¹¹ : MeasurableSpace V
W : Type u_3
inst✝¹⁰ : AddCommGroup W
inst✝⁹ : Module 𝕜 W
E : Type u_4
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace ℂ E
inst✝⁶ : TopologicalSpace 𝕜
inst✝⁵ : TopologicalRing 𝕜
inst✝⁴ : TopologicalSpace V
inst✝³ : BorelSpace V
inst✝² : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝¹ : CompleteSpace E
inst✝ : TopologicalSpace.FirstCountableTopology W
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
hf : Integrable f
w : W
v : V
⊢ ‖↑(↑e (↑Multiplicative.ofAdd (-↑(↑L v) w))) • f v‖ ≤ ‖f v‖
[PROOFSTEP]
rw [norm_smul, Complex.norm_eq_abs, abs_coe_circle, one_mul]
[GOAL]
case bound_integrable
𝕜 : Type u_1
inst✝¹⁴ : CommRing 𝕜
V : Type u_2
inst✝¹³ : AddCommGroup V
inst✝¹² : Module 𝕜 V
inst✝¹¹ : MeasurableSpace V
W : Type u_3
inst✝¹⁰ : AddCommGroup W
inst✝⁹ : Module 𝕜 W
E : Type u_4
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace ℂ E
inst✝⁶ : TopologicalSpace 𝕜
inst✝⁵ : TopologicalRing 𝕜
inst✝⁴ : TopologicalSpace V
inst✝³ : BorelSpace V
inst✝² : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝¹ : CompleteSpace E
inst✝ : TopologicalSpace.FirstCountableTopology W
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
hf : Integrable f
⊢ Integrable fun v => ‖f v‖
[PROOFSTEP]
exact hf.norm
[GOAL]
case h_cont
𝕜 : Type u_1
inst✝¹⁴ : CommRing 𝕜
V : Type u_2
inst✝¹³ : AddCommGroup V
inst✝¹² : Module 𝕜 V
inst✝¹¹ : MeasurableSpace V
W : Type u_3
inst✝¹⁰ : AddCommGroup W
inst✝⁹ : Module 𝕜 W
E : Type u_4
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace ℂ E
inst✝⁶ : TopologicalSpace 𝕜
inst✝⁵ : TopologicalRing 𝕜
inst✝⁴ : TopologicalSpace V
inst✝³ : BorelSpace V
inst✝² : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝¹ : CompleteSpace E
inst✝ : TopologicalSpace.FirstCountableTopology W
he : Continuous ↑e
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
hf : Integrable f
⊢ ∀ᵐ (a : V) ∂μ, Continuous fun x => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L a) x))) • f a
[PROOFSTEP]
rw [continuous_induced_rng] at he
[GOAL]
case h_cont
𝕜 : Type u_1
inst✝¹⁴ : CommRing 𝕜
V : Type u_2
inst✝¹³ : AddCommGroup V
inst✝¹² : Module 𝕜 V
inst✝¹¹ : MeasurableSpace V
W : Type u_3
inst✝¹⁰ : AddCommGroup W
inst✝⁹ : Module 𝕜 W
E : Type u_4
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace ℂ E
inst✝⁶ : TopologicalSpace 𝕜
inst✝⁵ : TopologicalRing 𝕜
inst✝⁴ : TopologicalSpace V
inst✝³ : BorelSpace V
inst✝² : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝¹ : CompleteSpace E
inst✝ : TopologicalSpace.FirstCountableTopology W
he : Continuous (Subtype.val ∘ ↑e)
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
hf : Integrable f
⊢ ∀ᵐ (a : V) ∂μ, Continuous fun x => ↑(↑e (↑Multiplicative.ofAdd (-↑(↑L a) x))) • f a
[PROOFSTEP]
refine' ae_of_all _ fun v => (he.comp (continuous_ofAdd.comp _)).smul continuous_const
[GOAL]
case h_cont
𝕜 : Type u_1
inst✝¹⁴ : CommRing 𝕜
V : Type u_2
inst✝¹³ : AddCommGroup V
inst✝¹² : Module 𝕜 V
inst✝¹¹ : MeasurableSpace V
W : Type u_3
inst✝¹⁰ : AddCommGroup W
inst✝⁹ : Module 𝕜 W
E : Type u_4
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace ℂ E
inst✝⁶ : TopologicalSpace 𝕜
inst✝⁵ : TopologicalRing 𝕜
inst✝⁴ : TopologicalSpace V
inst✝³ : BorelSpace V
inst✝² : TopologicalSpace W
e : Multiplicative 𝕜 →* { x // x ∈ 𝕊 }
μ : Measure V
L : V →ₗ[𝕜] W →ₗ[𝕜] 𝕜
inst✝¹ : CompleteSpace E
inst✝ : TopologicalSpace.FirstCountableTopology W
he : Continuous (Subtype.val ∘ ↑e)
hL : Continuous fun p => ↑(↑L p.fst) p.snd
f : V → E
hf : Integrable f
v : V
⊢ Continuous fun x => -↑(↑L v) x
[PROOFSTEP]
refine' (hL.comp (continuous_prod_mk.mpr ⟨continuous_const, continuous_id⟩)).neg
[GOAL]
⊢ (fun z => ↑expMapCircle (2 * π * ↑Multiplicative.toAdd z)) 1 = 1
[PROOFSTEP]
simp only
[GOAL]
⊢ ↑expMapCircle (2 * π * ↑Multiplicative.toAdd 1) = 1
[PROOFSTEP]
rw [toAdd_one, mul_zero, expMapCircle_zero]
[GOAL]
x y : Multiplicative ℝ
⊢ OneHom.toFun
{ toFun := fun z => ↑expMapCircle (2 * π * ↑Multiplicative.toAdd z),
map_one' := (_ : (fun z => ↑expMapCircle (2 * π * ↑Multiplicative.toAdd z)) 1 = 1) }
(x * y) =
OneHom.toFun
{ toFun := fun z => ↑expMapCircle (2 * π * ↑Multiplicative.toAdd z),
map_one' := (_ : (fun z => ↑expMapCircle (2 * π * ↑Multiplicative.toAdd z)) 1 = 1) }
x *
OneHom.toFun
{ toFun := fun z => ↑expMapCircle (2 * π * ↑Multiplicative.toAdd z),
map_one' := (_ : (fun z => ↑expMapCircle (2 * π * ↑Multiplicative.toAdd z)) 1 = 1) }
y
[PROOFSTEP]
simp only
[GOAL]
x y : Multiplicative ℝ
⊢ ↑expMapCircle (2 * π * ↑Multiplicative.toAdd (x * y)) =
↑expMapCircle (2 * π * ↑Multiplicative.toAdd x) * ↑expMapCircle (2 * π * ↑Multiplicative.toAdd y)
[PROOFSTEP]
rw [toAdd_mul, mul_add, expMapCircle_add]
[GOAL]
x : ℝ
⊢ ↑(↑fourierChar (↑Multiplicative.ofAdd x)) = Complex.exp (↑(2 * π * x) * Complex.I)
[PROOFSTEP]
rfl
[GOAL]
E : Type u_1
inst✝⁶ : NormedAddCommGroup E
inst✝⁵ : NormedSpace ℂ E
V : Type u_2
inst✝⁴ : AddCommGroup V
inst✝³ : Module ℝ V
inst✝² : MeasurableSpace V
W : Type u_3
inst✝¹ : AddCommGroup W
inst✝ : Module ℝ W
L : V →ₗ[ℝ] W →ₗ[ℝ] ℝ
μ : Measure V
f : V → E
w : W
⊢ VectorFourier.fourierIntegral fourierChar μ L f w =
∫ (v : V), Complex.exp (↑(-2 * π * ↑(↑L v) w) * Complex.I) • f v ∂μ
[PROOFSTEP]
simp_rw [VectorFourier.fourierIntegral, Real.fourierChar_apply, mul_neg, neg_mul]
[GOAL]
E✝ : Type u_1
inst✝³ : NormedAddCommGroup E✝
inst✝² : NormedSpace ℂ E✝
E : Type u_2
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℂ E
f : ℝ → E
w : ℝ
⊢ 𝓕 f w = ∫ (v : ℝ), Complex.exp (↑(-2 * π * v * w) * Complex.I) • f v
[PROOFSTEP]
simp_rw [fourierIntegral_def, Real.fourierChar_apply, mul_neg, neg_mul, mul_assoc]
|
[STATEMENT]
lemma O_mono1: "R \<subseteq> R' \<Longrightarrow> S O R \<subseteq> S O R'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. R \<subseteq> R' \<Longrightarrow> S O R \<subseteq> S O R'
[PROOF STEP]
by auto |
(* Author: Tobias Nipkow *)
header{* Isomorphisms Between Plane Graphs *}
theory PlaneGraphIso
imports Main Quasi_Order
begin
(* FIXME globalize *)
lemma image_image_id_if[simp]: "(!!x. f(f x) = x) \<Longrightarrow> f ` f ` M = M"
by (auto simp: image_iff)
declare not_None_eq [iff] not_Some_eq [iff]
text{* The symbols @{text "\<cong>"} and @{text "\<simeq>"} are overloaded. They
denote congruence and isomorphism on arbitrary types. On lists
(representing faces of graphs), @{text "\<cong>"} means congruence modulo
rotation; @{text "\<simeq>"} is currently unused. On graphs, @{text "\<simeq>"}
means isomorphism and is a weaker version of @{text "\<cong>"} (proper
isomorphism): @{text "\<simeq>"} also allows to reverse the orientation of
all faces. *}
consts
pr_isomorphic :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<cong>" 60)
(* isomorphic :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<simeq>" 60)
*)
(*
definition "congs" :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "\<cong>" 60) where
"F\<^sub>1 \<cong> (F\<^sub>2::'a list) \<equiv> \<exists>n. F\<^sub>2 = rotate n F\<^sub>1"
*)
definition Iso :: "('a list * 'a list) set" ("{\<cong>}") where
"{\<cong>} \<equiv> {(F\<^sub>1, F\<^sub>2). F\<^sub>1 \<cong> F\<^sub>2}"
text{* A plane graph is a set or list (for executability) of faces
(hence @{text Fgraph} and @{text fgraph}) and a face is a list of
nodes: *}
type_synonym 'a Fgraph = "'a list set"
type_synonym 'a fgraph = "'a list list"
subsection{* Equivalence of faces *}
text{* Two faces are equivalent modulo rotation: *}
defs (overloaded) congs_def:
"F\<^sub>1 \<cong> (F\<^sub>2::'a list) \<equiv> \<exists>n. F\<^sub>2 = rotate n F\<^sub>1"
lemma congs_refl[iff]: "(xs::'a list) \<cong> xs"
apply(simp add:congs_def)
apply(rule_tac x = 0 in exI)
apply (simp)
done
lemma congs_sym: assumes A: "(xs::'a list) \<cong> ys" shows "ys \<cong> xs"
proof (simp add:congs_def)
let ?l = "length xs"
from A obtain n where ys: "ys = rotate n xs" by(fastforce simp add:congs_def)
have "xs = rotate ?l xs" by simp
also have "\<dots> = rotate (?l - n mod ?l + n mod ?l) xs"
proof (cases)
assume "xs = []" thus ?thesis by simp
next
assume "xs \<noteq> []"
hence "n mod ?l < ?l" by simp
hence "?l = ?l - n mod ?l + n mod ?l" by arith
thus ?thesis by simp
qed
also have "\<dots> = rotate (?l - n mod ?l) (rotate (n mod ?l) xs)"
by(simp add:rotate_rotate)
also have "rotate (n mod ?l) xs = rotate n xs"
by(rule rotate_conv_mod[symmetric])
finally show "\<exists>m. xs = rotate m ys" by(fastforce simp add:ys)
qed
lemma congs_trans: "(xs::'a list) \<cong> ys \<Longrightarrow> ys \<cong> zs \<Longrightarrow> xs \<cong> zs"
apply(clarsimp simp:congs_def rotate_def)
apply(rename_tac m n)
apply(rule_tac x = "n+m" in exI)
apply (simp add:funpow_add)
done
lemma equiv_EqF: "equiv (UNIV::'a list set) {\<cong>}"
apply(unfold equiv_def sym_def trans_def refl_on_def)
apply(rule conjI)
apply simp
apply(rule conjI)
apply(fastforce intro:congs_sym)
apply(fastforce intro:congs_trans)
done
lemma congs_distinct:
"F\<^sub>1 \<cong> F\<^sub>2 \<Longrightarrow> distinct F\<^sub>2 = distinct F\<^sub>1"
by (auto simp: congs_def)
lemma congs_length:
"F\<^sub>1 \<cong> F\<^sub>2 \<Longrightarrow> length F\<^sub>2 = length F\<^sub>1"
by (auto simp: congs_def)
lemma congs_pres_nodes: "F\<^sub>1 \<cong> F\<^sub>2 \<Longrightarrow> set F\<^sub>1 = set F\<^sub>2"
by(clarsimp simp:congs_def)
lemma congs_map:
"F\<^sub>1 \<cong> F\<^sub>2 \<Longrightarrow> map f F\<^sub>1 \<cong> map f F\<^sub>2"
by (auto simp: congs_def rotate_map)
lemma congs_map_eq_iff:
"inj_on f (set xs \<union> set ys) \<Longrightarrow> (map f xs \<cong> map f ys) = (xs \<cong> ys)"
apply(simp add:congs_def)
apply(rule iffI)
apply(clarsimp simp: rotate_map)
apply(drule map_inj_on)
apply(simp add:Un_commute)
apply (fastforce)
apply clarsimp
apply(fastforce simp: rotate_map)
done
lemma list_cong_rev_iff[simp]:
"(rev xs \<cong> rev ys) = (xs \<cong> ys)"
apply(simp add:congs_def rotate_rev)
apply(rule iffI)
apply fast
apply clarify
apply(cases "length xs = 0")
apply simp
apply(case_tac "n mod length xs = 0")
apply(rule_tac x = "n" in exI)
apply simp
apply(subst rotate_conv_mod)
apply(rule_tac x = "length xs - n mod length xs" in exI)
apply simp
done
lemma singleton_list_cong_eq_iff[simp]:
"({xs::'a list} // {\<cong>} = {ys} // {\<cong>}) = (xs \<cong> ys)"
by(simp add: eq_equiv_class_iff2[OF equiv_EqF])
subsection{* Homomorphism and isomorphism *}
definition is_pr_Hom :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a Fgraph \<Rightarrow> 'b Fgraph \<Rightarrow> bool" where
"is_pr_Hom \<phi> Fs\<^sub>1 Fs\<^sub>2 \<equiv> (map \<phi> ` Fs\<^sub>1)//{\<cong>} = Fs\<^sub>2 //{\<cong>}"
definition is_pr_Iso :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a Fgraph \<Rightarrow> 'b Fgraph \<Rightarrow> bool" where
"is_pr_Iso \<phi> Fs\<^sub>1 Fs\<^sub>2 \<equiv> is_pr_Hom \<phi> Fs\<^sub>1 Fs\<^sub>2 \<and> inj_on \<phi> (\<Union>F \<in> Fs\<^sub>1. set F)"
definition is_pr_iso :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a fgraph \<Rightarrow> 'b fgraph \<Rightarrow> bool" where
"is_pr_iso \<phi> Fs\<^sub>1 Fs\<^sub>2 \<equiv> is_pr_Iso \<phi> (set Fs\<^sub>1) (set Fs\<^sub>2)"
text{* Homomorphisms preserve the set of nodes. *}
lemma UN_subset_iff: "((\<Union>i\<in>I. f i) \<subseteq> B) = (\<forall>i\<in>I. f i \<subseteq> B)"
by blast
declare Image_Collect_split[simp del]
lemma pr_Hom_pres_face_nodes:
"is_pr_Hom \<phi> Fs\<^sub>1 Fs\<^sub>2 \<Longrightarrow> (\<Union>F\<in>Fs\<^sub>1. {\<phi> ` (set F)}) = (\<Union>F\<in>Fs\<^sub>2. {set F})"
apply(clarsimp simp:is_pr_Hom_def quotient_def)
apply auto
apply(subgoal_tac "EX F' : Fs\<^sub>2. {\<cong>} `` {map \<phi> F} = {\<cong>} `` {F'}")
prefer 2 apply blast
apply (fastforce simp: eq_equiv_class_iff[OF equiv_EqF] dest!:congs_pres_nodes)
apply(subgoal_tac "EX F' : Fs\<^sub>1. {\<cong>} `` {map \<phi> F'} = {\<cong>} `` {F}")
apply (fastforce simp: eq_equiv_class_iff[OF equiv_EqF] dest!:congs_pres_nodes)
apply (erule equalityE)
apply(fastforce simp:UN_subset_iff)
done
lemma pr_Hom_pres_nodes:
"is_pr_Hom \<phi> Fs\<^sub>1 Fs\<^sub>2 \<Longrightarrow> \<phi> ` (\<Union>F\<in>Fs\<^sub>1. set F) = (\<Union>F\<in>Fs\<^sub>2. set F)"
apply(drule pr_Hom_pres_face_nodes)
apply(rule equalityI)
apply blast
apply(clarsimp)
apply(subgoal_tac "set F : (\<Union>F\<in>Fs\<^sub>2. {set F})")
prefer 2 apply blast
apply(subgoal_tac "set F : (\<Union>F\<in>Fs\<^sub>1. {\<phi> ` set F})")
prefer 2 apply blast
apply(subgoal_tac "EX F':Fs\<^sub>1. \<phi> ` set F' = set F")
prefer 2 apply blast
apply blast
done
text{* Therefore isomorphisms preserve cardinality of node set. *}
lemma pr_Iso_same_no_nodes:
"\<lbrakk> is_pr_Iso \<phi> Fs\<^sub>1 Fs\<^sub>2; finite Fs\<^sub>1 \<rbrakk>
\<Longrightarrow> card(\<Union>F\<in>Fs\<^sub>1. set F) = card(\<Union>F\<in>Fs\<^sub>2. set F)"
by(clarsimp simp add: is_pr_Iso_def pr_Hom_pres_nodes[symmetric] card_image)
lemma pr_iso_same_no_nodes:
"is_pr_iso \<phi> Fs\<^sub>1 Fs\<^sub>2 \<Longrightarrow> card(\<Union>F\<in>set Fs\<^sub>1. set F) = card(\<Union>F\<in>set Fs\<^sub>2. set F)"
by(simp add: is_pr_iso_def pr_Iso_same_no_nodes)
text{* Isomorphisms preserve the number of faces. *}
lemma pr_iso_same_no_faces:
assumes dist1: "distinct Fs\<^sub>1" and dist2: "distinct Fs\<^sub>2"
and inj1: "inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>1)"
and inj2: "inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>2)" and iso: "is_pr_iso \<phi> Fs\<^sub>1 Fs\<^sub>2"
shows "length Fs\<^sub>1 = length Fs\<^sub>2"
proof -
have injphi: "\<forall>F\<in>set Fs\<^sub>1. \<forall>F'\<in>set Fs\<^sub>1. inj_on \<phi> (set F \<union> set F')" using iso
by(auto simp:is_pr_iso_def is_pr_Iso_def is_pr_Hom_def inj_on_def)
have inj1': "inj_on (%xs. {xs} // {\<cong>}) (map \<phi> ` set Fs\<^sub>1)"
apply(rule inj_on_imageI)
apply(simp add:inj_on_def quotient_def eq_equiv_class_iff[OF equiv_EqF])
apply(simp add: congs_map_eq_iff injphi)
using inj1
apply(simp add:inj_on_def quotient_def eq_equiv_class_iff[OF equiv_EqF])
done
have "length Fs\<^sub>1 = card(set Fs\<^sub>1)" by(simp add:distinct_card[OF dist1])
also have "\<dots> = card(map \<phi> ` set Fs\<^sub>1)" using iso
by(auto simp:is_pr_iso_def is_pr_Iso_def is_pr_Hom_def inj_on_mapI card_image)
also have "\<dots> = card((map \<phi> ` set Fs\<^sub>1) // {\<cong>})"
by(simp add: card_quotient_disjoint[OF _ inj1'])
also have "(map \<phi> ` set Fs\<^sub>1)//{\<cong>} = set Fs\<^sub>2 // {\<cong>}"
using iso by(simp add: is_pr_iso_def is_pr_Iso_def is_pr_Hom_def)
also have "card(\<dots>) = card(set Fs\<^sub>2)"
by(simp add: card_quotient_disjoint[OF _ inj2])
also have "\<dots> = length Fs\<^sub>2" by(simp add:distinct_card[OF dist2])
finally show ?thesis .
qed
lemma is_Hom_distinct:
"\<lbrakk> is_pr_Hom \<phi> Fs\<^sub>1 Fs\<^sub>2; \<forall>F\<in>Fs\<^sub>1. distinct F; \<forall>F\<in>Fs\<^sub>2. distinct F \<rbrakk>
\<Longrightarrow> \<forall>F\<in>Fs\<^sub>1. distinct(map \<phi> F)"
apply(clarsimp simp add:is_pr_Hom_def)
apply(subgoal_tac "\<exists> F' \<in> Fs\<^sub>2. (map \<phi> F, F') : {\<cong>}")
apply(fastforce simp add: congs_def)
apply(subgoal_tac "\<exists> F' \<in> Fs\<^sub>2. {map \<phi> F}//{\<cong>} = {F'}//{\<cong>}")
apply clarify
apply(rule_tac x = F' in bexI)
apply(rule eq_equiv_class[OF _ equiv_EqF])
apply(simp add:singleton_quotient)
apply blast
apply assumption
apply(simp add:quotient_def)
apply(rotate_tac 1)
apply blast
done
lemma Collect_congs_eq_iff[simp]:
"Collect (op \<cong> x) = Collect (op \<cong> y) \<longleftrightarrow> (x \<cong> (y::'a list))"
using eq_equiv_class_iff2[OF equiv_EqF]
apply(simp add: quotient_def Iso_def)
apply blast
done
lemma is_pr_Hom_trans: assumes f: "is_pr_Hom f A B" and g: "is_pr_Hom g B C"
shows "is_pr_Hom (g o f) A C"
proof-
from f have f1: "ALL a:A. EX b:B. map f a \<cong> b"
apply(simp add: is_pr_Hom_def quotient_def Iso_def)
apply(erule equalityE)
apply blast
done
from f have f2: "ALL b:B. EX a:A. map f a \<cong> b"
apply(simp add: is_pr_Hom_def quotient_def Iso_def)
apply(erule equalityE)
apply blast
done
from g have g1: "ALL b:B. EX c:C. map g b \<cong> c"
apply(simp add: is_pr_Hom_def quotient_def Iso_def)
apply(erule equalityE)
apply blast
done
from g have g2: "ALL c:C. EX b:B. map g b \<cong> c"
apply(simp add: is_pr_Hom_def quotient_def Iso_def)
apply(erule equalityE)
apply blast
done
show ?thesis
apply(auto simp add: is_pr_Hom_def quotient_def Iso_def Image_def
map_comp_map[symmetric] image_comp simp del: map_map map_comp_map)
apply (metis congs_map[of _ _ g] congs_trans f1 g1)
by (metis congs_map[of _ _ g] congs_sym congs_trans f2 g2)
qed
lemma is_pr_Hom_rev:
"is_pr_Hom \<phi> A B \<Longrightarrow> is_pr_Hom \<phi> (rev ` A) (rev ` B)"
apply(auto simp add: is_pr_Hom_def quotient_def Image_def Iso_def rev_map[symmetric])
apply(erule equalityE)
apply blast
apply(erule equalityE)
apply blast
done
text{* A kind of recursion rule, a first step towards executability: *}
lemma is_pr_Iso_rec:
"\<lbrakk> inj_on (%xs. {xs}//{\<cong>}) Fs\<^sub>1; inj_on (%xs. {xs}//{\<cong>}) Fs\<^sub>2; F\<^sub>1 \<in> Fs\<^sub>1 \<rbrakk> \<Longrightarrow>
is_pr_Iso \<phi> Fs\<^sub>1 Fs\<^sub>2 =
(\<exists>F\<^sub>2 \<in> Fs\<^sub>2. length F\<^sub>1 = length F\<^sub>2 \<and> is_pr_Iso \<phi> (Fs\<^sub>1 - {F\<^sub>1}) (Fs\<^sub>2 - {F\<^sub>2})
\<and> (\<exists>n. map \<phi> F\<^sub>1 = rotate n F\<^sub>2)
\<and> inj_on \<phi> (\<Union>F\<in>Fs\<^sub>1. set F))"
apply(drule mk_disjoint_insert[of F\<^sub>1])
apply clarify
apply(rename_tac Fs\<^sub>1')
apply(rule iffI)
apply (clarsimp simp add:is_pr_Iso_def)
apply(clarsimp simp:is_pr_Hom_def quotient_diff1)
apply(drule_tac s="?a // ?b" in sym)
apply(clarsimp)
apply(subgoal_tac "{\<cong>} `` {map \<phi> F\<^sub>1} : Fs\<^sub>2 // {\<cong>}")
prefer 2 apply(simp add:quotient_def)
apply(erule quotientE)
apply(rename_tac F\<^sub>2)
apply(drule eq_equiv_class[OF _ equiv_EqF])
apply blast
apply(rule_tac x = F\<^sub>2 in bexI)
prefer 2 apply assumption
apply(rule conjI)
apply(clarsimp simp: congs_def)
apply(rule conjI)
apply(subgoal_tac "{\<cong>} `` {F\<^sub>2} = {\<cong>} `` {map \<phi> F\<^sub>1}")
prefer 2
apply(rule equiv_class_eq[OF equiv_EqF])
apply(fastforce intro: congs_sym)
apply(subgoal_tac "{F\<^sub>2}//{\<cong>} = {map \<phi> F\<^sub>1}//{\<cong>}")
prefer 2 apply(simp add:singleton_quotient)
apply(subgoal_tac "\<forall>F\<in>Fs\<^sub>1'. \<not> (map \<phi> F) \<cong> (map \<phi> F\<^sub>1)")
apply(fastforce simp:Iso_def quotient_def Image_Collect_split simp del: Collect_congs_eq_iff
dest!: eq_equiv_class[OF _ equiv_EqF])
apply clarify
apply(subgoal_tac "inj_on \<phi> (set F \<union> set F\<^sub>1)")
prefer 2
apply(erule subset_inj_on)
apply(blast)
apply(clarsimp simp add:congs_map_eq_iff)
apply(subgoal_tac "{\<cong>} `` {F\<^sub>1} = {\<cong>} `` {F}")
apply(simp add:singleton_quotient)
apply(rule equiv_class_eq[OF equiv_EqF])
apply(blast intro:congs_sym)
apply(subgoal_tac "F\<^sub>2 \<cong> (map \<phi> F\<^sub>1)")
apply (simp add:congs_def inj_on_Un)
apply(clarsimp intro!:congs_sym)
apply(clarsimp simp add: is_pr_Iso_def is_pr_Hom_def quotient_diff1)
apply (simp add:singleton_quotient)
apply(subgoal_tac "F\<^sub>2 \<cong> (map \<phi> F\<^sub>1)")
prefer 2 apply(fastforce simp add:congs_def)
apply(subgoal_tac "{\<cong>}``{map \<phi> F\<^sub>1} = {\<cong>}``{F\<^sub>2}")
prefer 2
apply(rule equiv_class_eq[OF equiv_EqF])
apply(fastforce intro:congs_sym)
apply(subgoal_tac "{\<cong>}``{F\<^sub>2} \<in> Fs\<^sub>2 // {\<cong>}")
prefer 2 apply(erule quotientI)
apply (simp add:insert_absorb quotient_def)
done
lemma is_iso_Cons:
"\<lbrakk> distinct (F\<^sub>1#Fs\<^sub>1'); distinct Fs\<^sub>2;
inj_on (%xs.{xs}//{\<cong>}) (set(F\<^sub>1#Fs\<^sub>1')); inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>2) \<rbrakk>
\<Longrightarrow>
is_pr_iso \<phi> (F\<^sub>1#Fs\<^sub>1') Fs\<^sub>2 =
(\<exists>F\<^sub>2 \<in> set Fs\<^sub>2. length F\<^sub>1 = length F\<^sub>2 \<and> is_pr_iso \<phi> Fs\<^sub>1' (remove1 F\<^sub>2 Fs\<^sub>2)
\<and> (\<exists>n. map \<phi> F\<^sub>1 = rotate n F\<^sub>2)
\<and> inj_on \<phi> (set F\<^sub>1 \<union> (\<Union>F\<in>set Fs\<^sub>1'. set F)))"
apply(simp add:is_pr_iso_def)
apply(subst is_pr_Iso_rec[where ?F\<^sub>1.0 = F\<^sub>1])
apply(simp_all)
done
subsection{* Isomorphism tests *}
lemma map_upd_submap:
"x \<notin> dom m \<Longrightarrow> (m(x \<mapsto> y) \<subseteq>\<^sub>m m') = (m' x = Some y \<and> m \<subseteq>\<^sub>m m')"
apply(simp add:map_le_def dom_def)
apply(rule iffI)
apply(rule conjI) apply (blast intro:sym)
apply clarify
apply(case_tac "a=x")
apply auto
done
lemma map_of_zip_submap: "\<lbrakk> length xs = length ys; distinct xs \<rbrakk> \<Longrightarrow>
(map_of (zip xs ys) \<subseteq>\<^sub>m Some \<circ> f) = (map f xs = ys)"
apply(induct rule: list_induct2)
apply(simp)
apply (clarsimp simp: map_upd_submap simp del:o_apply fun_upd_apply)
apply simp
done
primrec pr_iso_test0 :: "('a ~=> 'b) \<Rightarrow> 'a fgraph \<Rightarrow> 'b fgraph \<Rightarrow> bool" where
"pr_iso_test0 m [] Fs\<^sub>2 = (Fs\<^sub>2 = [])"
| "pr_iso_test0 m (F\<^sub>1#Fs\<^sub>1) Fs\<^sub>2 =
(\<exists>F\<^sub>2 \<in> set Fs\<^sub>2. length F\<^sub>1 = length F\<^sub>2 \<and>
(\<exists>n. let m' = map_of(zip F\<^sub>1 (rotate n F\<^sub>2)) in
if m \<subseteq>\<^sub>m m ++ m' \<and> inj_on (m++m') (dom(m++m'))
then pr_iso_test0 (m ++ m') Fs\<^sub>1 (remove1 F\<^sub>2 Fs\<^sub>2) else False))"
lemma map_compatI: "\<lbrakk> f \<subseteq>\<^sub>m Some o h; g \<subseteq>\<^sub>m Some o h \<rbrakk> \<Longrightarrow> f \<subseteq>\<^sub>m f++g"
by (fastforce simp add: map_le_def map_add_def dom_def split:option.splits)
lemma inj_on_map_addI1:
"\<lbrakk> inj_on m A; m \<subseteq>\<^sub>m m++m'; A \<subseteq> dom m \<rbrakk> \<Longrightarrow> inj_on (m++m') A"
apply (clarsimp simp add: inj_on_def map_add_def map_le_def dom_def
split:option.splits)
apply(rule conjI)
apply fastforce
apply auto
apply fastforce
apply (rename_tac x a y)
apply(subgoal_tac "m x = Some a")
prefer 2 apply (fastforce)
apply(subgoal_tac "m y = Some a")
prefer 2 apply (fastforce)
apply(subgoal_tac "m x = m y")
prefer 2 apply simp
apply (blast)
done
lemma map_image_eq: "\<lbrakk> A \<subseteq> dom m; m \<subseteq>\<^sub>m m' \<rbrakk> \<Longrightarrow> m ` A = m' ` A"
by(force simp:map_le_def dom_def split:option.splits)
lemma inj_on_map_add_Un:
"\<lbrakk> inj_on m (dom m); inj_on m' (dom m'); m \<subseteq>\<^sub>m Some o f; m' \<subseteq>\<^sub>m Some o f;
inj_on f (dom m' \<union> dom m); A = dom m'; B = dom m \<rbrakk>
\<Longrightarrow> inj_on (m ++ m') (A \<union> B)"
apply(simp add:inj_on_Un)
apply(rule conjI)
apply(fastforce intro!: inj_on_map_addI1 map_compatI)
apply(clarify)
apply(subgoal_tac "m ++ m' \<subseteq>\<^sub>m Some \<circ> f")
prefer 2 apply(fast intro:map_add_le_mapI map_compatI)
apply(subgoal_tac "dom m' - dom m \<subseteq> dom(m++m')")
prefer 2 apply(fastforce)
apply(insert map_image_eq[of "dom m' - dom m" "m++m'" "Some o f"])
apply(subgoal_tac "dom m - dom m' \<subseteq> dom(m++m')")
prefer 2 apply(fastforce)
apply(insert map_image_eq[of "dom m - dom m'" "m++m'" "Some o f"])
apply (clarsimp simp add: image_comp [symmetric])
apply blast
done
lemma map_of_zip_eq_SomeD: "length xs = length ys \<Longrightarrow>
map_of (zip xs ys) x = Some y \<Longrightarrow> y \<in> set ys"
apply(induct rule:list_induct2)
apply simp
apply (auto split:if_splits)
done
lemma inj_on_map_of_zip:
"\<lbrakk> length xs = length ys; distinct ys \<rbrakk>
\<Longrightarrow> inj_on (map_of (zip xs ys)) (set xs)"
apply(induct rule:list_induct2)
apply simp
apply clarsimp
apply(rule conjI)
apply(erule inj_on_fun_updI)
apply(simp add:image_def)
apply clarsimp
apply(drule (1) map_of_zip_eq_SomeD[OF _ sym])
apply fast
apply(clarsimp simp add:image_def)
apply(drule (1) map_of_zip_eq_SomeD[OF _ sym])
apply fast
done
lemma pr_iso_test0_correct: "\<And>m Fs\<^sub>2.
\<lbrakk> \<forall>F\<in>set Fs\<^sub>1. distinct F; \<forall>F\<in>set Fs\<^sub>2. distinct F;
distinct Fs\<^sub>1; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>1);
distinct Fs\<^sub>2; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>2); inj_on m (dom m) \<rbrakk> \<Longrightarrow>
pr_iso_test0 m Fs\<^sub>1 Fs\<^sub>2 =
(\<exists>\<phi>. is_pr_iso \<phi> Fs\<^sub>1 Fs\<^sub>2 \<and> m \<subseteq>\<^sub>m Some o \<phi> \<and>
inj_on \<phi> (dom m \<union> (\<Union>F\<in>set Fs\<^sub>1. set F)))"
apply(induct Fs\<^sub>1)
apply(simp add:inj_on_def dom_def)
apply(rule iffI)
apply (simp add:is_pr_iso_def is_pr_Iso_def is_pr_Hom_def)
apply(rule_tac x = "the o m" in exI)
apply (fastforce simp: map_le_def)
apply (clarsimp simp:is_pr_iso_def is_pr_Iso_def is_pr_Hom_def)
apply(rename_tac F\<^sub>1 Fs\<^sub>1' m Fs\<^sub>2)
apply(clarsimp simp:Let_def Ball_def)
apply(simp add: is_iso_Cons)
apply(rule iffI)
apply clarify
apply(clarsimp simp add:map_of_zip_submap inj_on_diff)
apply(rule_tac x = \<phi> in exI)
apply(rule conjI)
apply(rule_tac x = F\<^sub>2 in bexI)
prefer 2 apply assumption
apply(frule map_add_le_mapE)
apply(simp add:map_of_zip_submap is_pr_iso_def is_pr_Iso_def)
apply(rule conjI)
apply blast
apply(erule subset_inj_on)
apply blast
apply(rule conjI)
apply(blast intro: map_le_trans)
apply(erule subset_inj_on)
apply blast
apply(clarsimp simp: inj_on_diff)
apply(rule_tac x = F\<^sub>2 in bexI)
prefer 2 apply assumption
apply simp
apply(rule_tac x = n in exI)
apply(rule conjI)
apply clarsimp
apply(rule_tac x = \<phi> in exI)
apply simp
apply(rule conjI)
apply(fastforce intro!:map_add_le_mapI simp:map_of_zip_submap)
apply(simp add:Un_ac)
apply(rule context_conjI)
apply(simp add:map_of_zip_submap[symmetric])
apply(erule (1) map_compatI)
apply(simp add:map_of_zip_submap[symmetric])
apply(erule inj_on_map_add_Un)
apply(simp add:inj_on_map_of_zip)
apply assumption
apply assumption
apply simp
apply(erule subset_inj_on)
apply fast
apply simp
apply(rule refl)
done
corollary pr_iso_test0_corr:
"\<lbrakk> \<forall>F\<in>set Fs\<^sub>1. distinct F; \<forall>F\<in>set Fs\<^sub>2. distinct F;
distinct Fs\<^sub>1; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>1);
distinct Fs\<^sub>2; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>2) \<rbrakk> \<Longrightarrow>
pr_iso_test0 empty Fs\<^sub>1 Fs\<^sub>2 = (\<exists>\<phi>. is_pr_iso \<phi> Fs\<^sub>1 Fs\<^sub>2)"
apply(subst pr_iso_test0_correct)
apply assumption+
apply simp
apply (simp add:is_pr_iso_def is_pr_Iso_def)
done
text{* Now we bound the number of rotations needed. We have to exclude
the empty face @{term"[]"} to be able to restrict the search to
@{prop"n < length xs"} (which would otherwise be vacuous). *}
primrec pr_iso_test1 :: "('a ~=> 'b) \<Rightarrow> 'a fgraph \<Rightarrow> 'b fgraph \<Rightarrow> bool" where
"pr_iso_test1 m [] Fs\<^sub>2 = (Fs\<^sub>2 = [])"
| "pr_iso_test1 m (F\<^sub>1#Fs\<^sub>1) Fs\<^sub>2 =
(\<exists>F\<^sub>2 \<in> set Fs\<^sub>2. length F\<^sub>1 = length F\<^sub>2 \<and>
(\<exists>n < length F\<^sub>2. let m' = map_of(zip F\<^sub>1 (rotate n F\<^sub>2)) in
if m \<subseteq>\<^sub>m m ++ m' \<and> inj_on (m++m') (dom(m++m'))
then pr_iso_test1 (m ++ m') Fs\<^sub>1 (remove1 F\<^sub>2 Fs\<^sub>2) else False))"
lemma test0_conv_test1:
"!!m Fs\<^sub>2. [] \<notin> set Fs\<^sub>2 \<Longrightarrow> pr_iso_test1 m Fs\<^sub>1 Fs\<^sub>2 = pr_iso_test0 m Fs\<^sub>1 Fs\<^sub>2"
apply(induct Fs\<^sub>1)
apply simp
apply simp
apply(rule iffI)
apply blast
apply (clarsimp simp:Let_def)
apply(rule_tac x = F\<^sub>2 in bexI)
prefer 2 apply assumption
apply simp
apply(subgoal_tac "F\<^sub>2 \<noteq> []")
prefer 2 apply blast
apply(rule_tac x = "n mod length F\<^sub>2" in exI)
apply(simp add:rotate_conv_mod[symmetric])
done
text{* Thus correctness carries over to @{text pr_iso_test1}: *}
corollary pr_iso_test1_corr:
"\<lbrakk> \<forall>F\<in>set Fs\<^sub>1. distinct F; \<forall>F\<in>set Fs\<^sub>2. distinct F; [] \<notin> set Fs\<^sub>2;
distinct Fs\<^sub>1; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>1);
distinct Fs\<^sub>2; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>2) \<rbrakk> \<Longrightarrow>
pr_iso_test1 empty Fs\<^sub>1 Fs\<^sub>2 = (\<exists>\<phi>. is_pr_iso \<phi> Fs\<^sub>1 Fs\<^sub>2)"
by(simp add: test0_conv_test1 pr_iso_test0_corr)
subsubsection{* Implementing maps by lists *}
text{* The representation are lists of pairs with no repetition in the
first or second component. *}
definition oneone :: "('a * 'b)list \<Rightarrow> bool" where
"oneone xys \<equiv> distinct(map fst xys) \<and> distinct(map snd xys)"
declare oneone_def[simp]
type_synonym
('a,'b)tester = "('a * 'b)list \<Rightarrow> ('a * 'b)list \<Rightarrow> bool"
type_synonym
('a,'b)merger = "('a * 'b)list \<Rightarrow> ('a * 'b)list \<Rightarrow> ('a * 'b)list"
primrec pr_iso_test2 :: "('a,'b)tester \<Rightarrow> ('a,'b)merger \<Rightarrow>
('a * 'b)list \<Rightarrow> 'a fgraph \<Rightarrow> 'b fgraph \<Rightarrow> bool" where
"pr_iso_test2 tst mrg I [] Fs\<^sub>2 = (Fs\<^sub>2 = [])"
| "pr_iso_test2 tst mrg I (F\<^sub>1#Fs\<^sub>1) Fs\<^sub>2 =
(\<exists>F\<^sub>2 \<in> set Fs\<^sub>2. length F\<^sub>1 = length F\<^sub>2 \<and>
(\<exists>n < length F\<^sub>2. let I' = zip F\<^sub>1 (rotate n F\<^sub>2) in
if tst I' I
then pr_iso_test2 tst mrg (mrg I' I) Fs\<^sub>1 (remove1 F\<^sub>2 Fs\<^sub>2) else False))"
lemma notin_range_map_of:
"y \<notin> snd ` set xys \<Longrightarrow> Some y \<notin> range(map_of xys)"
apply(induct xys)
apply (simp add:image_def)
apply(clarsimp split:if_splits)
done
lemma inj_on_map_upd:
"\<lbrakk> inj_on m (dom m); Some y \<notin> range m \<rbrakk> \<Longrightarrow> inj_on (m(x\<mapsto>y)) (dom m)"
apply(simp add:inj_on_def dom_def image_def)
apply (blast intro:sym)
done
lemma lem: "Ball (set xs) P \<Longrightarrow> Ball (set (remove1 x xs)) P = True"
by(induct xs) simp_all
lemma pr_iso_test2_conv_1:
"!!I Fs\<^sub>2.
\<lbrakk> \<forall>I I'. oneone I \<longrightarrow> oneone I' \<longrightarrow>
tst I' I = (let m = map_of I; m' = map_of I'
in m \<subseteq>\<^sub>m m ++ m' \<and> inj_on (m++m') (dom(m++m')));
\<forall>I I'. oneone I \<longrightarrow> oneone I' \<longrightarrow> tst I' I
\<longrightarrow> map_of(mrg I' I) = map_of I ++ map_of I';
\<forall>I I'. oneone I & oneone I' \<longrightarrow> tst I' I \<longrightarrow> oneone (mrg I' I);
oneone I;
\<forall>F \<in> set Fs\<^sub>1. distinct F; \<forall>F \<in> set Fs\<^sub>2. distinct F \<rbrakk> \<Longrightarrow>
pr_iso_test2 tst mrg I Fs\<^sub>1 Fs\<^sub>2 = pr_iso_test1 (map_of I) Fs\<^sub>1 Fs\<^sub>2"
apply(induct Fs\<^sub>1)
apply simp
apply(simp add:Let_def lem inj_on_map_of_zip del: mod_less cong: conj_cong)
done
text{* A simple implementation *}
definition compat :: "('a,'b)tester" where
"compat I I' ==
\<forall>(x,y) \<in> set I. \<forall>(x',y') \<in> set I'. (x = x') = (y = y')"
lemma image_map_upd:
"x \<notin> dom m \<Longrightarrow> m(x\<mapsto>y) ` A = m ` (A-{x}) \<union> (if x \<in> A then {Some y} else {})"
by(auto simp:image_def dom_def)
lemma image_map_of_conv_Image:
"!!A. \<lbrakk> distinct(map fst xys) \<rbrakk>
\<Longrightarrow> map_of xys ` A = Some ` (set xys `` A) \<union> (if A \<subseteq> fst ` set xys then {} else {None})"
apply (induct xys)
apply (simp add:image_def Image_def Collect_conv_if)
apply (simp add:image_map_upd dom_map_of_conv_image_fst)
apply(erule thin_rl)
apply (clarsimp simp:image_def Image_def)
apply((rule conjI, clarify)+, fastforce)
apply fastforce
apply(clarify)
apply((rule conjI, clarify)+, fastforce)
apply fastforce
apply fastforce
apply fastforce
done
lemma [simp]: "m++m' ` (dom m' - A) = m' ` (dom m' - A)"
apply(clarsimp simp add:map_add_def image_def dom_def inj_on_def split:option.splits)
apply auto
apply (blast intro:sym)
apply (blast intro:sym)
apply (rule_tac x = xa in bexI)
prefer 2 apply blast
apply simp
done
declare Diff_subset [iff]
lemma compat_correct:
"\<lbrakk> oneone I; oneone I' \<rbrakk> \<Longrightarrow>
compat I' I = (let m = map_of I; m' = map_of I'
in m \<subseteq>\<^sub>m m ++ m' \<and> inj_on (m++m') (dom(m++m')))"
apply(simp add: compat_def Let_def map_le_iff_map_add_commute)
apply(rule iffI)
apply(rule context_conjI)
apply(rule ext)
apply (fastforce simp add:map_add_def split:option.split)
apply(simp add:inj_on_Un)
apply(drule sym)
apply simp
apply(simp add: dom_map_of_conv_image_fst image_map_of_conv_Image)
apply(simp add: image_def Image_def)
apply fastforce
apply clarsimp
apply(rename_tac a b aa ba)
apply(rule iffI)
apply (clarsimp simp: fun_eq_iff)
apply(erule_tac x = aa in allE)
apply (simp add:map_add_def)
apply (clarsimp simp:dom_map_of_conv_image_fst)
apply(simp (no_asm_use) add:inj_on_def)
apply(drule_tac x = a in bspec)
apply force
apply(drule_tac x = aa in bspec)
apply force
apply(erule mp)
apply simp
apply(drule sym)
apply simp
done
corollary compat_corr:
"\<forall>I I'. oneone I \<longrightarrow> oneone I' \<longrightarrow>
compat I' I = (let m = map_of I; m' = map_of I'
in m \<subseteq>\<^sub>m m ++ m' \<and> inj_on (m++m') (dom(m++m')))"
by(simp add: compat_correct)
definition merge0 :: "('a,'b)merger" where
"merge0 I' I \<equiv> [xy \<leftarrow> I'. fst xy \<notin> fst ` set I] @ I"
lemma help1:
"distinct(map fst xys) \<Longrightarrow> map_of (filter P xys) =
map_of xys |` {x. \<exists>y. (x,y) \<in> set xys \<and> P(x,y)}"
apply(induct xys)
apply simp
apply(rule ext)
apply (simp add:restrict_map_def)
apply force
done
lemma merge0_correct:
"\<forall>I I'. oneone I \<longrightarrow> oneone I' \<longrightarrow> compat I' I
\<longrightarrow> map_of(merge0 I' I) = map_of I ++ map_of I'"
apply(simp add:compat_def merge0_def help1 fun_eq_iff map_add_def restrict_map_def split:option.split)
apply fastforce
done
lemma merge0_inv:
"\<forall>I I'. oneone I \<and> oneone I' \<longrightarrow> compat I' I \<longrightarrow> oneone (merge0 I' I)"
apply(auto simp add:merge0_def distinct_map compat_def split_def)
apply(blast intro:subset_inj_on)+
done
corollary pr_iso_test2_corr:
"\<lbrakk> \<forall>F\<in>set Fs\<^sub>1. distinct F; \<forall>F\<in>set Fs\<^sub>2. distinct F; [] \<notin> set Fs\<^sub>2;
distinct Fs\<^sub>1; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>1);
distinct Fs\<^sub>2; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>2) \<rbrakk> \<Longrightarrow>
pr_iso_test2 compat merge0 [] Fs\<^sub>1 Fs\<^sub>2 = (\<exists>\<phi>. is_pr_iso \<phi> Fs\<^sub>1 Fs\<^sub>2)"
by(simp add: pr_iso_test2_conv_1[OF compat_corr merge0_correct merge0_inv]
pr_iso_test1_corr)
text{* Implementing merge as a recursive function: *}
primrec merge :: "('a,'b)merger" where
"merge [] I = I"
| "merge (xy#xys) I = (let (x,y) = xy in
if \<forall> (x',y') \<in> set I. x \<noteq> x' then xy # merge xys I else merge xys I)"
lemma merge_conv_merge0: "merge I' I = merge0 I' I"
apply(induct I')
apply(simp add:merge0_def)
apply(force simp add:Let_def list_all_iff merge0_def)
done
primrec pr_iso_test_rec :: "('a * 'b)list \<Rightarrow> 'a fgraph \<Rightarrow> 'b fgraph \<Rightarrow> bool" where
"pr_iso_test_rec I [] Fs\<^sub>2 = (Fs\<^sub>2 = [])"
| "pr_iso_test_rec I (F\<^sub>1#Fs\<^sub>1) Fs\<^sub>2 =
(\<exists> F\<^sub>2 \<in> set Fs\<^sub>2. length F\<^sub>1 = length F\<^sub>2 \<and>
(\<exists>n < length F\<^sub>2. let I' = zip F\<^sub>1 (rotate n F\<^sub>2) in
compat I' I \<and> pr_iso_test_rec (merge I' I) Fs\<^sub>1 (remove1 F\<^sub>2 Fs\<^sub>2)))"
lemma pr_iso_test_rec_conv_2:
"!!I Fs\<^sub>2. pr_iso_test_rec I Fs\<^sub>1 Fs\<^sub>2 = pr_iso_test2 compat merge0 I Fs\<^sub>1 Fs\<^sub>2"
apply(induct Fs\<^sub>1)
apply simp
apply(auto simp: merge_conv_merge0 list_ex_iff Bex_def Let_def)
done
corollary pr_iso_test_rec_corr:
"\<lbrakk> \<forall>F\<in>set Fs\<^sub>1. distinct F; \<forall>F\<in>set Fs\<^sub>2. distinct F; [] \<notin> set Fs\<^sub>2;
distinct Fs\<^sub>1; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>1);
distinct Fs\<^sub>2; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>2) \<rbrakk> \<Longrightarrow>
pr_iso_test_rec [] Fs\<^sub>1 Fs\<^sub>2 = (\<exists>\<phi>. is_pr_iso \<phi> Fs\<^sub>1 Fs\<^sub>2)"
by(simp add: pr_iso_test_rec_conv_2 pr_iso_test2_corr)
definition pr_iso_test :: "'a fgraph \<Rightarrow> 'b fgraph \<Rightarrow> bool" where
"pr_iso_test Fs\<^sub>1 Fs\<^sub>2 = pr_iso_test_rec [] Fs\<^sub>1 Fs\<^sub>2"
corollary pr_iso_test_correct:
"\<lbrakk> \<forall>F\<in>set Fs\<^sub>1. distinct F; \<forall>F\<in>set Fs\<^sub>2. distinct F; [] \<notin> set Fs\<^sub>2;
distinct Fs\<^sub>1; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>1);
distinct Fs\<^sub>2; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>2) \<rbrakk> \<Longrightarrow>
pr_iso_test Fs\<^sub>1 Fs\<^sub>2 = (\<exists>\<phi>. is_pr_iso \<phi> Fs\<^sub>1 Fs\<^sub>2)"
apply(simp add:pr_iso_test_def pr_iso_test_rec_corr)
done
subsubsection{* `Improper' Isomorphisms *}
definition is_Iso :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a Fgraph \<Rightarrow> 'b Fgraph \<Rightarrow> bool" where
"is_Iso \<phi> Fs\<^sub>1 Fs\<^sub>2 \<equiv> is_pr_Iso \<phi> Fs\<^sub>1 Fs\<^sub>2 \<or> is_pr_Iso \<phi> Fs\<^sub>1 (rev ` Fs\<^sub>2)"
definition is_iso :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a fgraph \<Rightarrow> 'b fgraph \<Rightarrow> bool" where
"is_iso \<phi> Fs\<^sub>1 Fs\<^sub>2 \<equiv> is_Iso \<phi> (set Fs\<^sub>1) (set Fs\<^sub>2)"
definition iso_fgraph :: "'a fgraph \<Rightarrow> 'a fgraph \<Rightarrow> bool" (infix "\<simeq>" 60) where
"g\<^sub>1 \<simeq> g\<^sub>2 \<equiv> \<exists>\<phi>. is_iso \<phi> g\<^sub>1 g\<^sub>2"
lemma iso_fgraph_trans: assumes "f \<simeq> (g::'a fgraph)" and "g \<simeq> h" shows "f \<simeq> h"
proof-
{ fix \<phi> \<phi>' assume "is_pr_Hom \<phi> (set f) (set g)" "inj_on \<phi> (\<Union>F\<in>set f. set F)"
"is_pr_Hom \<phi>' (set g) (set h)" "inj_on \<phi>' (\<Union>F\<in>set g. set F)"
hence "is_pr_Hom (\<phi>' \<circ> \<phi>) (set f) (set h) \<and>
inj_on (\<phi>' \<circ> \<phi>) (\<Union>F\<in>set f. set F)"
by(simp add: is_pr_Hom_trans comp_inj_on pr_Hom_pres_nodes)
} moreover
{ fix \<phi> \<phi>' assume "is_pr_Hom \<phi> (set f) (set g)" "inj_on \<phi> (\<Union>F\<in>set f. set F)"
"is_pr_Hom \<phi>' (set g) (rev ` set h)" "inj_on \<phi>' (\<Union>F\<in>set g. set F)"
hence "is_pr_Hom (\<phi>' \<circ> \<phi>) (set f) (rev ` set h) \<and>
inj_on (\<phi>' \<circ> \<phi>) (\<Union>F\<in>set f. set F)"
by(simp add: is_pr_Hom_trans comp_inj_on pr_Hom_pres_nodes)
} moreover
{ fix \<phi> \<phi>' assume "is_pr_Hom \<phi> (set f) (rev ` set g)" "inj_on \<phi> (\<Union>F\<in>set f. set F)"
"is_pr_Hom \<phi>' (set g) (set h)" "inj_on \<phi>' (\<Union>F\<in>set g. set F)"
with this(3)[THEN is_pr_Hom_rev]
have "is_pr_Hom (\<phi>' \<circ> \<phi>) (set f) (rev ` set h) \<and>
inj_on (\<phi>' \<circ> \<phi>) (\<Union>F\<in>set f. set F)"
by(simp add: is_pr_Hom_trans comp_inj_on pr_Hom_pres_nodes)
} moreover
{ fix \<phi> \<phi>' assume "is_pr_Hom \<phi> (set f) (rev ` set g)" "inj_on \<phi> (\<Union>F\<in>set f. set F)"
"is_pr_Hom \<phi>' (set g) (rev ` set h)" "inj_on \<phi>' (\<Union>F\<in>set g. set F)"
with this(3)[THEN is_pr_Hom_rev]
have "is_pr_Hom (\<phi>' \<circ> \<phi>) (set f) (set h) \<and>
inj_on (\<phi>' \<circ> \<phi>) (\<Union>F\<in>set f. set F)"
by(simp add: is_pr_Hom_trans comp_inj_on pr_Hom_pres_nodes)
} ultimately show ?thesis using assms
by(simp add: iso_fgraph_def is_iso_def is_Iso_def is_pr_Iso_def) blast
qed
definition iso_test :: "'a fgraph \<Rightarrow> 'b fgraph \<Rightarrow> bool" where
"iso_test g\<^sub>1 g\<^sub>2 \<longleftrightarrow> pr_iso_test g\<^sub>1 g\<^sub>2 \<or> pr_iso_test g\<^sub>1 (map rev g\<^sub>2)"
theorem iso_correct:
"\<lbrakk> \<forall>F\<in>set Fs\<^sub>1. distinct F; \<forall>F\<in>set Fs\<^sub>2. distinct F; [] \<notin> set Fs\<^sub>2;
distinct Fs\<^sub>1; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>1);
distinct Fs\<^sub>2; inj_on (%xs.{xs}//{\<cong>}) (set Fs\<^sub>2) \<rbrakk> \<Longrightarrow>
iso_test Fs\<^sub>1 Fs\<^sub>2 = (Fs\<^sub>1 \<simeq> Fs\<^sub>2)"
apply(simp add:iso_test_def pr_iso_test_correct iso_fgraph_def)
apply(subst pr_iso_test_correct)
apply simp
apply simp
apply (simp add:image_def)
apply simp
apply simp
apply (simp add:distinct_map)
apply (simp add:inj_on_image_iff)
apply(simp add:is_iso_def is_Iso_def is_pr_iso_def)
apply blast
done
lemma iso_fgraph_refl[iff]: "g \<simeq> g"
apply(simp add: iso_fgraph_def)
apply(rule_tac x = "id" in exI)
apply(simp add: is_iso_def is_Iso_def is_pr_Iso_def is_pr_Hom_def id_def)
done
subsection{* Elementhood and containment modulo *}
interpretation qle_gr: quasi_order "op \<simeq>"
proof qed (auto intro:iso_fgraph_trans)
abbreviation qle_gr_in :: "'a fgraph \<Rightarrow> 'a fgraph set \<Rightarrow> bool" (infix "\<in>\<^sub>\<simeq>" 60)
where "x \<in>\<^sub>\<simeq> M \<equiv> qle_gr.in_qle x M"
abbreviation qle_gr_sub :: "'a fgraph set \<Rightarrow> 'a fgraph set \<Rightarrow> bool" (infix "\<subseteq>\<^sub>\<simeq>" 60)
where "x \<subseteq>\<^sub>\<simeq> M \<equiv> qle_gr.subseteq_qle x M"
abbreviation qle_gr_eq :: "'a fgraph set \<Rightarrow> 'a fgraph set \<Rightarrow> bool" (infix "=\<^sub>\<simeq>" 60)
where "x =\<^sub>\<simeq> M \<equiv> qle_gr.seteq_qle x M"
end |
/-
Copyright (c) 2020 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau
-/
import linear_algebra.basic
/-!
# modular equivalence for submodule
-/
open submodule
variables {R : Type*} [ring R]
variables {M : Type*} [add_comm_group M] [module R M] (U U₁ U₂ : submodule R M)
variables {x x₁ x₂ y y₁ y₂ z z₁ z₂ : M}
variables {N : Type*} [add_comm_group N] [module R N] (V V₁ V₂ : submodule R N)
/-- A predicate saying two elements of a module are equivalent modulo a submodule. -/
def smodeq (x y : M) : Prop :=
(submodule.quotient.mk x : U.quotient) = submodule.quotient.mk y
notation x ` ≡ `:50 y ` [SMOD `:50 N `]`:0 := smodeq N x y
variables {U U₁ U₂}
protected lemma smodeq.def : x ≡ y [SMOD U] ↔
(submodule.quotient.mk x : U.quotient) = submodule.quotient.mk y := iff.rfl
namespace smodeq
@[simp] theorem top : x ≡ y [SMOD (⊤ : submodule R M)] :=
(submodule.quotient.eq ⊤).2 mem_top
@[simp] theorem bot : x ≡ y [SMOD (⊥ : submodule R M)] ↔ x = y :=
by rw [smodeq.def, submodule.quotient.eq, mem_bot, sub_eq_zero]
@[mono] theorem mono (HU : U₁ ≤ U₂) (hxy : x ≡ y [SMOD U₁]) : x ≡ y [SMOD U₂] :=
(submodule.quotient.eq U₂).2 $ HU $ (submodule.quotient.eq U₁).1 hxy
@[refl] theorem refl : x ≡ x [SMOD U] := eq.refl _
@[symm] theorem symm (hxy : x ≡ y [SMOD U]) : y ≡ x [SMOD U] := hxy.symm
@[trans] theorem trans (hxy : x ≡ y [SMOD U]) (hyz : y ≡ z [SMOD U]) : x ≡ z [SMOD U] :=
hxy.trans hyz
theorem add (hxy₁ : x₁ ≡ y₁ [SMOD U]) (hxy₂ : x₂ ≡ y₂ [SMOD U]) : x₁ + x₂ ≡ y₁ + y₂ [SMOD U] :=
by { rw smodeq.def at hxy₁ hxy₂ ⊢, simp_rw [quotient.mk_add, hxy₁, hxy₂] }
theorem smul (hxy : x ≡ y [SMOD U]) (c : R) : c • x ≡ c • y [SMOD U] :=
by { rw smodeq.def at hxy ⊢, simp_rw [quotient.mk_smul, hxy] }
theorem zero : x ≡ 0 [SMOD U] ↔ x ∈ U :=
by rw [smodeq.def, submodule.quotient.eq, sub_zero]
theorem map (hxy : x ≡ y [SMOD U]) (f : M →ₗ[R] N) : f x ≡ f y [SMOD U.map f] :=
(submodule.quotient.eq _).2 $ f.map_sub x y ▸ mem_map_of_mem $ (submodule.quotient.eq _).1 hxy
theorem comap {f : M →ₗ[R] N} (hxy : f x ≡ f y [SMOD V]) : x ≡ y [SMOD V.comap f] :=
(submodule.quotient.eq _).2 $ show f (x - y) ∈ V,
from (f.map_sub x y).symm ▸ (submodule.quotient.eq _).1 hxy
end smodeq
|
theory Collecting
imports Complete_Lattice Big_Step ACom
begin
subsection "The generic Step function"
notation
sup (infixl "\<squnion>" 65) and
inf (infixl "\<sqinter>" 70) and
bot ("\<bottom>") and
top ("\<top>")
context
fixes f :: "vname \<Rightarrow> aexp \<Rightarrow> 'a \<Rightarrow> 'a::sup"
fixes g :: "bexp \<Rightarrow> 'a \<Rightarrow> 'a"
begin
fun Step :: "'a \<Rightarrow> 'a acom \<Rightarrow> 'a acom" where
"Step S (SKIP {Q}) = (SKIP {S})" |
"Step S (x ::= e {Q}) =
x ::= e {f x e S}" |
"Step S (C1;; C2) = Step S C1;; Step (post C1) C2" |
"Step S (IF b THEN {P1} C1 ELSE {P2} C2 {Q}) =
IF b THEN {g b S} Step P1 C1 ELSE {g (Not b) S} Step P2 C2
{post C1 \<squnion> post C2}" |
"Step S ({I} WHILE b DO {P} C {Q}) =
{S \<squnion> post C} WHILE b DO {g b I} Step P C {g (Not b) I}"
end
lemma strip_Step[simp]: "strip(Step f g S C) = strip C"
by(induct C arbitrary: S) auto
subsection "Collecting Semantics of Commands"
subsubsection "Annotated commands as a complete lattice"
instantiation acom :: (order) order
begin
definition less_eq_acom :: "('a::order)acom \<Rightarrow> 'a acom \<Rightarrow> bool" where
"C1 \<le> C2 \<longleftrightarrow> strip C1 = strip C2 \<and> (\<forall>p<size(annos C1). anno C1 p \<le> anno C2 p)"
definition less_acom :: "'a acom \<Rightarrow> 'a acom \<Rightarrow> bool" where
"less_acom x y = (x \<le> y \<and> \<not> y \<le> x)"
instance
proof (standard, goal_cases)
case 1 show ?case by(simp add: less_acom_def)
next
case 2 thus ?case by(auto simp: less_eq_acom_def)
next
case 3 thus ?case by(fastforce simp: less_eq_acom_def size_annos)
next
case 4 thus ?case
by(fastforce simp: le_antisym less_eq_acom_def size_annos
eq_acom_iff_strip_anno)
qed
end
lemma less_eq_acom_annos:
"C1 \<le> C2 \<longleftrightarrow> strip C1 = strip C2 \<and> list_all2 (op \<le>) (annos C1) (annos C2)"
by(auto simp add: less_eq_acom_def anno_def list_all2_conv_all_nth size_annos_same2)
lemma SKIP_le[simp]: "SKIP {S} \<le> c \<longleftrightarrow> (\<exists>S'. c = SKIP {S'} \<and> S \<le> S')"
by (cases c) (auto simp:less_eq_acom_def anno_def)
lemma Assign_le[simp]: "x ::= e {S} \<le> c \<longleftrightarrow> (\<exists>S'. c = x ::= e {S'} \<and> S \<le> S')"
by (cases c) (auto simp:less_eq_acom_def anno_def)
lemma Seq_le[simp]: "C1;;C2 \<le> C \<longleftrightarrow> (\<exists>C1' C2'. C = C1';;C2' \<and> C1 \<le> C1' \<and> C2 \<le> C2')"
apply (cases C)
apply(auto simp: less_eq_acom_annos list_all2_append size_annos_same2)
done
lemma If_le[simp]: "IF b THEN {p1} C1 ELSE {p2} C2 {S} \<le> C \<longleftrightarrow>
(\<exists>p1' p2' C1' C2' S'. C = IF b THEN {p1'} C1' ELSE {p2'} C2' {S'} \<and>
p1 \<le> p1' \<and> p2 \<le> p2' \<and> C1 \<le> C1' \<and> C2 \<le> C2' \<and> S \<le> S')"
apply (cases C)
apply(auto simp: less_eq_acom_annos list_all2_append size_annos_same2)
done
lemma While_le[simp]: "{I} WHILE b DO {p} C {P} \<le> W \<longleftrightarrow>
(\<exists>I' p' C' P'. W = {I'} WHILE b DO {p'} C' {P'} \<and> C \<le> C' \<and> p \<le> p' \<and> I \<le> I' \<and> P \<le> P')"
apply (cases W)
apply(auto simp: less_eq_acom_annos list_all2_append size_annos_same2)
done
lemma mono_post: "C \<le> C' \<Longrightarrow> post C \<le> post C'"
using annos_ne[of C']
by(auto simp: post_def less_eq_acom_def last_conv_nth[OF annos_ne] anno_def
dest: size_annos_same)
definition Inf_acom :: "com \<Rightarrow> 'a::complete_lattice acom set \<Rightarrow> 'a acom" where
"Inf_acom c M = annotate (\<lambda>p. INF C:M. anno C p) c"
global_interpretation
Complete_Lattice "{C. strip C = c}" "Inf_acom c" for c
proof (standard, goal_cases)
case 1 thus ?case
by(auto simp: Inf_acom_def less_eq_acom_def size_annos intro:INF_lower)
next
case 2 thus ?case
by(auto simp: Inf_acom_def less_eq_acom_def size_annos intro:INF_greatest)
next
case 3 thus ?case by(auto simp: Inf_acom_def)
qed
subsubsection "Collecting semantics"
definition "step = Step (\<lambda>x e S. {s(x := aval e s) |s. s : S}) (\<lambda>b S. {s:S. bval b s})"
definition CS :: "com \<Rightarrow> state set acom" where
"CS c = lfp c (step UNIV)"
lemma mono2_Step: fixes C1 C2 :: "'a::semilattice_sup acom"
assumes "!!x e S1 S2. S1 \<le> S2 \<Longrightarrow> f x e S1 \<le> f x e S2"
"!!b S1 S2. S1 \<le> S2 \<Longrightarrow> g b S1 \<le> g b S2"
shows "C1 \<le> C2 \<Longrightarrow> S1 \<le> S2 \<Longrightarrow> Step f g S1 C1 \<le> Step f g S2 C2"
proof(induction S1 C1 arbitrary: C2 S2 rule: Step.induct)
case 1 thus ?case by(auto)
next
case 2 thus ?case by (auto simp: assms(1))
next
case 3 thus ?case by(auto simp: mono_post)
next
case 4 thus ?case
by(auto simp: subset_iff assms(2))
(metis mono_post le_supI1 le_supI2)+
next
case 5 thus ?case
by(auto simp: subset_iff assms(2))
(metis mono_post le_supI1 le_supI2)+
qed
lemma mono2_step: "C1 \<le> C2 \<Longrightarrow> S1 \<subseteq> S2 \<Longrightarrow> step S1 C1 \<le> step S2 C2"
unfolding step_def by(rule mono2_Step) auto
lemma mono_step: "mono (step S)"
by(blast intro: monoI mono2_step)
lemma strip_step: "strip(step S C) = strip C"
by (induction C arbitrary: S) (auto simp: step_def)
lemma lfp_cs_unfold: "lfp c (step S) = step S (lfp c (step S))"
apply(rule lfp_unfold[OF _ mono_step])
apply(simp add: strip_step)
done
lemma CS_unfold: "CS c = step UNIV (CS c)"
by (metis CS_def lfp_cs_unfold)
lemma strip_CS[simp]: "strip(CS c) = c"
by(simp add: CS_def index_lfp[simplified])
subsubsection "Relation to big-step semantics"
lemma asize_nz: "asize(c::com) \<noteq> 0"
by (metis length_0_conv length_annos_annotate annos_ne)
lemma post_Inf_acom:
"\<forall>C\<in>M. strip C = c \<Longrightarrow> post (Inf_acom c M) = \<Inter>(post ` M)"
apply(subgoal_tac "\<forall>C\<in>M. size(annos C) = asize c")
apply(simp add: post_anno_asize Inf_acom_def asize_nz neq0_conv[symmetric])
apply(simp add: size_annos)
done
lemma post_lfp: "post(lfp c f) = (\<Inter>{post C|C. strip C = c \<and> f C \<le> C})"
by(auto simp add: lfp_def post_Inf_acom)
lemma big_step_post_step:
"\<lbrakk> (c, s) \<Rightarrow> t; strip C = c; s \<in> S; step S C \<le> C \<rbrakk> \<Longrightarrow> t \<in> post C"
proof(induction arbitrary: C S rule: big_step_induct)
case Skip thus ?case by(auto simp: strip_eq_SKIP step_def post_def)
next
case Assign thus ?case
by(fastforce simp: strip_eq_Assign step_def post_def)
next
case Seq thus ?case
by(fastforce simp: strip_eq_Seq step_def post_def last_append annos_ne)
next
case IfTrue thus ?case apply(auto simp: strip_eq_If step_def post_def)
by (metis (lifting,full_types) mem_Collect_eq set_mp)
next
case IfFalse thus ?case apply(auto simp: strip_eq_If step_def post_def)
by (metis (lifting,full_types) mem_Collect_eq set_mp)
next
case (WhileTrue b s1 c' s2 s3)
from WhileTrue.prems(1) obtain I P C' Q where "C = {I} WHILE b DO {P} C' {Q}" "strip C' = c'"
by(auto simp: strip_eq_While)
from WhileTrue.prems(3) `C = _`
have "step P C' \<le> C'" "{s \<in> I. bval b s} \<le> P" "S \<le> I" "step (post C') C \<le> C"
by (auto simp: step_def post_def)
have "step {s \<in> I. bval b s} C' \<le> C'"
by (rule order_trans[OF mono2_step[OF order_refl `{s \<in> I. bval b s} \<le> P`] `step P C' \<le> C'`])
have "s1: {s:I. bval b s}" using `s1 \<in> S` `S \<subseteq> I` `bval b s1` by auto
note s2_in_post_C' = WhileTrue.IH(1)[OF `strip C' = c'` this `step {s \<in> I. bval b s} C' \<le> C'`]
from WhileTrue.IH(2)[OF WhileTrue.prems(1) s2_in_post_C' `step (post C') C \<le> C`]
show ?case .
next
case (WhileFalse b s1 c') thus ?case
by (force simp: strip_eq_While step_def post_def)
qed
lemma big_step_lfp: "\<lbrakk> (c,s) \<Rightarrow> t; s \<in> S \<rbrakk> \<Longrightarrow> t \<in> post(lfp c (step S))"
by(auto simp add: post_lfp intro: big_step_post_step)
lemma big_step_CS: "(c,s) \<Rightarrow> t \<Longrightarrow> t : post(CS c)"
by(simp add: CS_def big_step_lfp)
end
|
Formal statement is: lemma continuous_on_inv: fixes f :: "'a::topological_space \<Rightarrow> 'b::t2_space" assumes "continuous_on s f" and "compact s" and "\<forall>x\<in>s. g (f x) = x" shows "continuous_on (f ` s) g" Informal statement is: If $f$ is a continuous function from a compact set $S$ to a Hausdorff space $Y$, and $g$ is a function from $Y$ to $S$ such that $g(f(x)) = x$ for all $x \in S$, then $g$ is continuous. |
What is culture? A moving essay, a beautiful photograph, a musical imprint. It’s a trip with loved ones that will be remembered forever, a bowl of natural flavors, a handicraft that was made with patience and care. At PAD, culture is about experiencing life in all its glorious and fascinating ways. We want to tell the stories of artists, musicians, travelers, chefs, farmers and creators and makers of all kinds. Here, they can share their love and compassion with our global community.
Oh My Food, It’s Ok To Be Ugly! |
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import data.multiset.sum
import data.finset.card
/-!
# Disjoint sum of finsets
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file defines the disjoint sum of two finsets as `finset (α ⊕ β)`. Beware not to confuse with
the `finset.sum` operation which computes the additive sum.
## Main declarations
* `finset.disj_sum`: `s.disj_sum t` is the disjoint sum of `s` and `t`.
-/
open function multiset sum
namespace finset
variables {α β : Type*} (s : finset α) (t : finset β)
/-- Disjoint sum of finsets. -/
def disj_sum : finset (α ⊕ β) := ⟨s.1.disj_sum t.1, s.2.disj_sum t.2⟩
@[simp] lemma val_disj_sum : (s.disj_sum t).1 = s.1.disj_sum t.1 := rfl
@[simp] lemma empty_disj_sum : (∅ : finset α).disj_sum t = t.map embedding.inr :=
val_inj.1 $ multiset.zero_disj_sum _
@[simp] lemma disj_sum_empty : s.disj_sum (∅ : finset β) = s.map embedding.inl :=
val_inj.1 $ multiset.disj_sum_zero _
@[simp] lemma card_disj_sum : (s.disj_sum t).card = s.card + t.card := multiset.card_disj_sum _ _
lemma disjoint_map_inl_map_inr : disjoint (s.map embedding.inl) (t.map embedding.inr) :=
by { simp_rw [disjoint_left, mem_map], rintro x ⟨a, _, rfl⟩ ⟨b, _, ⟨⟩⟩ }
@[simp]
lemma map_inl_disj_union_map_inr :
(s.map embedding.inl).disj_union (t.map embedding.inr) (disjoint_map_inl_map_inr _ _) =
s.disj_sum t := rfl
variables {s t} {s₁ s₂ : finset α} {t₁ t₂ : finset β} {a : α} {b : β} {x : α ⊕ β}
lemma mem_disj_sum : x ∈ s.disj_sum t ↔ (∃ a, a ∈ s ∧ inl a = x) ∨ ∃ b, b ∈ t ∧ inr b = x :=
multiset.mem_disj_sum
@[simp] lemma inl_mem_disj_sum : inl a ∈ s.disj_sum t ↔ a ∈ s := inl_mem_disj_sum
@[simp] lemma inr_mem_disj_sum : inr b ∈ s.disj_sum t ↔ b ∈ t := inr_mem_disj_sum
lemma disj_sum_mono (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) : s₁.disj_sum t₁ ⊆ s₂.disj_sum t₂ :=
val_le_iff.1 $ disj_sum_mono (val_le_iff.2 hs) (val_le_iff.2 ht)
lemma disj_sum_mono_left (t : finset β) : monotone (λ s : finset α, s.disj_sum t) :=
λ s₁ s₂ hs, disj_sum_mono hs subset.rfl
lemma disj_sum_mono_right (s : finset α) : monotone (s.disj_sum : finset β → finset (α ⊕ β)) :=
λ t₁ t₂, disj_sum_mono subset.rfl
lemma disj_sum_ssubset_disj_sum_of_ssubset_of_subset (hs : s₁ ⊂ s₂) (ht : t₁ ⊆ t₂) :
s₁.disj_sum t₁ ⊂ s₂.disj_sum t₂ :=
val_lt_iff.1 $ disj_sum_lt_disj_sum_of_lt_of_le (val_lt_iff.2 hs) (val_le_iff.2 ht)
lemma disj_sum_ssubset_disj_sum_of_subset_of_ssubset (hs : s₁ ⊆ s₂) (ht : t₁ ⊂ t₂) :
s₁.disj_sum t₁ ⊂ s₂.disj_sum t₂ :=
val_lt_iff.1 $ disj_sum_lt_disj_sum_of_le_of_lt (val_le_iff.2 hs) (val_lt_iff.2 ht)
lemma disj_sum_strict_mono_left (t : finset β) : strict_mono (λ s : finset α, s.disj_sum t) :=
λ s₁ s₂ hs, disj_sum_ssubset_disj_sum_of_ssubset_of_subset hs subset.rfl
lemma disj_sum_strict_mono_right (s : finset α) :
strict_mono (s.disj_sum : finset β → finset (α ⊕ β)) :=
λ s₁ s₂, disj_sum_ssubset_disj_sum_of_subset_of_ssubset subset.rfl
end finset
|
/-
Copyright (c) 2019 Zhouhang Zhou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yaël Dillies
-/
import data.set.pointwise.smul
import order.filter.n_ary
import order.filter.ultrafilter
/-!
# Pointwise operations on filters
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file defines pointwise operations on filters. This is useful because usual algebraic operations
distribute over pointwise operations. For example,
* `(f₁ * f₂).map m = f₁.map m * f₂.map m`
* `𝓝 (x * y) = 𝓝 x * 𝓝 y`
## Main declarations
* `0` (`filter.has_zero`): Pure filter at `0 : α`, or alternatively principal filter at `0 : set α`.
* `1` (`filter.has_one`): Pure filter at `1 : α`, or alternatively principal filter at `1 : set α`.
* `f + g` (`filter.has_add`): Addition, filter generated by all `s + t` where `s ∈ f` and `t ∈ g`.
* `f * g` (`filter.has_mul`): Multiplication, filter generated by all `s * t` where `s ∈ f` and
`t ∈ g`.
* `-f` (`filter.has_neg`): Negation, filter of all `-s` where `s ∈ f`.
* `f⁻¹` (`filter.has_inv`): Inversion, filter of all `s⁻¹` where `s ∈ f`.
* `f - g` (`filter.has_sub`): Subtraction, filter generated by all `s - t` where `s ∈ f` and
`t ∈ g`.
* `f / g` (`filter.has_div`): Division, filter generated by all `s / t` where `s ∈ f` and `t ∈ g`.
* `f +ᵥ g` (`filter.has_vadd`): Scalar addition, filter generated by all `s +ᵥ t` where `s ∈ f` and
`t ∈ g`.
* `f -ᵥ g` (`filter.has_vsub`): Scalar subtraction, filter generated by all `s -ᵥ t` where `s ∈ f`
and `t ∈ g`.
* `f • g` (`filter.has_smul`): Scalar multiplication, filter generated by all `s • t` where
`s ∈ f` and `t ∈ g`.
* `a +ᵥ f` (`filter.has_vadd_filter`): Translation, filter of all `a +ᵥ s` where `s ∈ f`.
* `a • f` (`filter.has_smul_filter`): Scaling, filter of all `a • s` where `s ∈ f`.
For `α` a semigroup/monoid, `filter α` is a semigroup/monoid.
As an unfortunate side effect, this means that `n • f`, where `n : ℕ`, is ambiguous between
pointwise scaling and repeated pointwise addition. See note [pointwise nat action].
## Implementation notes
We put all instances in the locale `pointwise`, so that these instances are not available by
default. Note that we do not mark them as reducible (as argued by note [reducible non-instances])
since we expect the locale to be open whenever the instances are actually used (and making the
instances reducible changes the behavior of `simp`.
## Tags
filter multiplication, filter addition, pointwise addition, pointwise multiplication,
-/
open function set
open_locale filter pointwise
variables {F α β γ δ ε : Type*}
namespace filter
/-! ### `0`/`1` as filters -/
section has_one
variables [has_one α] {f : filter α} {s : set α}
/-- `1 : filter α` is defined as the filter of sets containing `1 : α` in locale `pointwise`. -/
@[to_additive "`0 : filter α` is defined as the filter of sets containing `0 : α` in locale
`pointwise`."]
protected def has_one : has_one (filter α) := ⟨pure 1⟩
localized "attribute [instance] filter.has_one filter.has_zero" in pointwise
@[simp, to_additive] lemma mem_one : s ∈ (1 : filter α) ↔ (1 : α) ∈ s := mem_pure
@[to_additive] lemma one_mem_one : (1 : set α) ∈ (1 : filter α) := mem_pure.2 one_mem_one
@[simp, to_additive] lemma pure_one : pure 1 = (1 : filter α) := rfl
@[simp, to_additive] lemma principal_one : 𝓟 1 = (1 : filter α) := principal_singleton _
@[to_additive] lemma one_ne_bot : (1 : filter α).ne_bot := filter.pure_ne_bot
@[simp, to_additive] protected lemma map_one' (f : α → β) : (1 : filter α).map f = pure (f 1) := rfl
@[simp, to_additive] lemma le_one_iff : f ≤ 1 ↔ (1 : set α) ∈ f := le_pure_iff
@[to_additive] protected lemma ne_bot.le_one_iff (h : f.ne_bot) : f ≤ 1 ↔ f = 1 := h.le_pure_iff
@[simp, to_additive] lemma eventually_one {p : α → Prop} : (∀ᶠ x in 1, p x) ↔ p 1 := eventually_pure
@[simp, to_additive] lemma tendsto_one {a : filter β} {f : β → α} :
tendsto f a 1 ↔ ∀ᶠ x in a, f x = 1 :=
tendsto_pure
@[simp, to_additive] lemma one_prod_one [has_one β] : (1 : filter α) ×ᶠ (1 : filter β) = 1 :=
prod_pure_pure
/-- `pure` as a `one_hom`. -/
@[to_additive "`pure` as a `zero_hom`."]
def pure_one_hom : one_hom α (filter α) := ⟨pure, pure_one⟩
@[simp, to_additive]
variables [has_one β]
@[simp, to_additive]
protected lemma map_one [one_hom_class F α β] (φ : F) : map φ 1 = 1 :=
by rw [filter.map_one', map_one, pure_one]
end has_one
/-! ### Filter negation/inversion -/
section has_inv
variables [has_inv α] {f g : filter α} {s : set α} {a : α}
/-- The inverse of a filter is the pointwise preimage under `⁻¹` of its sets. -/
@[to_additive "The negation of a filter is the pointwise preimage under `-` of its sets."]
instance : has_inv (filter α) := ⟨map has_inv.inv⟩
@[simp, to_additive] protected lemma map_inv : f.map has_inv.inv = f⁻¹ := rfl
@[to_additive] lemma mem_inv : s ∈ f⁻¹ ↔ has_inv.inv ⁻¹' s ∈ f := iff.rfl
@[to_additive] protected lemma inv_le_inv (hf : f ≤ g) : f⁻¹ ≤ g⁻¹ := map_mono hf
@[simp, to_additive] lemma inv_pure : (pure a : filter α)⁻¹ = pure a⁻¹ := rfl
@[simp, to_additive] lemma inv_eq_bot_iff : f⁻¹ = ⊥ ↔ f = ⊥ := map_eq_bot_iff
@[simp, to_additive] lemma ne_bot_inv_iff : f⁻¹.ne_bot ↔ ne_bot f := map_ne_bot_iff _
@[to_additive] lemma ne_bot.inv : f.ne_bot → f⁻¹.ne_bot := λ h, h.map _
end has_inv
section has_involutive_inv
variables [has_involutive_inv α] {f g : filter α} {s : set α}
@[to_additive] lemma inv_mem_inv (hs : s ∈ f) : s⁻¹ ∈ f⁻¹ := by rwa [mem_inv, inv_preimage, inv_inv]
/-- Inversion is involutive on `filter α` if it is on `α`. -/
@[to_additive "Negation is involutive on `filter α` if it is on `α`."]
protected def has_involutive_inv : has_involutive_inv (filter α) :=
{ inv_inv := λ f, map_map.trans $ by rw [inv_involutive.comp_self, map_id],
..filter.has_inv }
localized "attribute [instance] filter.has_involutive_inv filter.has_involutive_neg" in pointwise
@[simp, to_additive] protected lemma inv_le_inv_iff : f⁻¹ ≤ g⁻¹ ↔ f ≤ g :=
⟨λ h, inv_inv f ▸ inv_inv g ▸ filter.inv_le_inv h, filter.inv_le_inv⟩
@[to_additive] lemma inv_le_iff_le_inv : f⁻¹ ≤ g ↔ f ≤ g⁻¹ :=
by rw [← filter.inv_le_inv_iff, inv_inv]
@[simp, to_additive] lemma inv_le_self : f⁻¹ ≤ f ↔ f⁻¹ = f :=
⟨λ h, h.antisymm $ inv_le_iff_le_inv.1 h, eq.le⟩
end has_involutive_inv
/-! ### Filter addition/multiplication -/
section has_mul
variables [has_mul α] [has_mul β] {f f₁ f₂ g g₁ g₂ h : filter α} {s t : set α} {a b : α}
/-- The filter `f * g` is generated by `{s * t | s ∈ f, t ∈ g}` in locale `pointwise`. -/
@[to_additive "The filter `f + g` is generated by `{s + t | s ∈ f, t ∈ g}` in locale `pointwise`."]
protected def has_mul : has_mul (filter α) :=
/- This is defeq to `map₂ (*) f g`, but the hypothesis unfolds to `t₁ * t₂ ⊆ s` rather than all the
way to `set.image2 (*) t₁ t₂ ⊆ s`. -/
⟨λ f g, { sets := {s | ∃ t₁ t₂, t₁ ∈ f ∧ t₂ ∈ g ∧ t₁ * t₂ ⊆ s}, ..map₂ (*) f g }⟩
localized "attribute [instance] filter.has_mul filter.has_add" in pointwise
@[simp, to_additive] lemma map₂_mul : map₂ (*) f g = f * g := rfl
@[to_additive] lemma mem_mul : s ∈ f * g ↔ ∃ t₁ t₂, t₁ ∈ f ∧ t₂ ∈ g ∧ t₁ * t₂ ⊆ s := iff.rfl
@[to_additive] lemma mul_mem_mul : s ∈ f → t ∈ g → s * t ∈ f * g := image2_mem_map₂
@[simp, to_additive] lemma bot_mul : ⊥ * g = ⊥ := map₂_bot_left
@[simp, to_additive] lemma mul_bot : f * ⊥ = ⊥ := map₂_bot_right
@[simp, to_additive] lemma mul_eq_bot_iff : f * g = ⊥ ↔ f = ⊥ ∨ g = ⊥ := map₂_eq_bot_iff
@[simp, to_additive] lemma mul_ne_bot_iff : (f * g).ne_bot ↔ f.ne_bot ∧ g.ne_bot := map₂_ne_bot_iff
@[to_additive] lemma ne_bot.mul : ne_bot f → ne_bot g → ne_bot (f * g) := ne_bot.map₂
@[to_additive] lemma ne_bot.of_mul_left : (f * g).ne_bot → f.ne_bot := ne_bot.of_map₂_left
@[to_additive] lemma ne_bot.of_mul_right : (f * g).ne_bot → g.ne_bot := ne_bot.of_map₂_right
@[simp, to_additive] lemma pure_mul : pure a * g = g.map ((*) a) := map₂_pure_left
@[simp, to_additive] lemma mul_pure : f * pure b = f.map (* b) := map₂_pure_right
@[simp, to_additive] lemma pure_mul_pure : (pure a : filter α) * pure b = pure (a * b) := map₂_pure
@[simp, to_additive] lemma le_mul_iff : h ≤ f * g ↔ ∀ ⦃s⦄, s ∈ f → ∀ ⦃t⦄, t ∈ g → s * t ∈ h :=
le_map₂_iff
@[to_additive] instance covariant_mul : covariant_class (filter α) (filter α) (*) (≤) :=
⟨λ f g h, map₂_mono_left⟩
@[to_additive] instance covariant_swap_mul : covariant_class (filter α) (filter α) (swap (*)) (≤) :=
⟨λ f g h, map₂_mono_right⟩
@[to_additive]
protected lemma map_mul [mul_hom_class F α β] (m : F) : (f₁ * f₂).map m = f₁.map m * f₂.map m :=
map_map₂_distrib $ map_mul m
/-- `pure` operation as a `mul_hom`. -/
@[to_additive "The singleton operation as an `add_hom`."]
def pure_mul_hom : α →ₙ* filter α := ⟨pure, λ a b, pure_mul_pure.symm⟩
@[simp, to_additive] lemma coe_pure_mul_hom : (pure_mul_hom : α → filter α) = pure := rfl
@[simp, to_additive] lemma pure_mul_hom_apply (a : α) : pure_mul_hom a = pure a := rfl
end has_mul
/-! ### Filter subtraction/division -/
section div
variables [has_div α] {f f₁ f₂ g g₁ g₂ h : filter α} {s t : set α} {a b : α}
/-- The filter `f / g` is generated by `{s / t | s ∈ f, t ∈ g}` in locale `pointwise`. -/
@[to_additive "The filter `f - g` is generated by `{s - t | s ∈ f, t ∈ g}` in locale `pointwise`."]
protected def has_div : has_div (filter α) :=
/- This is defeq to `map₂ (/) f g`, but the hypothesis unfolds to `t₁ / t₂ ⊆ s` rather than all the
way to `set.image2 (/) t₁ t₂ ⊆ s`. -/
⟨λ f g, { sets := {s | ∃ t₁ t₂, t₁ ∈ f ∧ t₂ ∈ g ∧ t₁ / t₂ ⊆ s}, ..map₂ (/) f g }⟩
localized "attribute [instance] filter.has_div filter.has_sub" in pointwise
@[simp, to_additive] lemma map₂_div : map₂ (/) f g = f / g := rfl
@[to_additive] lemma mem_div : s ∈ f / g ↔ ∃ t₁ t₂, t₁ ∈ f ∧ t₂ ∈ g ∧ t₁ / t₂ ⊆ s := iff.rfl
@[to_additive] lemma div_mem_div : s ∈ f → t ∈ g → s / t ∈ f / g := image2_mem_map₂
@[simp, to_additive] lemma bot_div : ⊥ / g = ⊥ := map₂_bot_left
@[simp, to_additive] lemma div_bot : f / ⊥ = ⊥ := map₂_bot_right
@[simp, to_additive] lemma div_eq_bot_iff : f / g = ⊥ ↔ f = ⊥ ∨ g = ⊥ := map₂_eq_bot_iff
@[simp, to_additive] lemma div_ne_bot_iff : (f / g).ne_bot ↔ f.ne_bot ∧ g.ne_bot := map₂_ne_bot_iff
@[to_additive] lemma ne_bot.div : ne_bot f → ne_bot g → ne_bot (f / g) := ne_bot.map₂
@[to_additive] lemma ne_bot.of_div_left : (f / g).ne_bot → f.ne_bot := ne_bot.of_map₂_left
@[to_additive] lemma ne_bot.of_div_right : (f / g).ne_bot → g.ne_bot := ne_bot.of_map₂_right
@[simp, to_additive] lemma pure_div : pure a / g = g.map ((/) a) := map₂_pure_left
@[simp, to_additive] lemma div_pure : f / pure b = f.map (/ b) := map₂_pure_right
@[simp, to_additive] lemma pure_div_pure : (pure a : filter α) / pure b = pure (a / b) := map₂_pure
@[to_additive] protected lemma div_le_div : f₁ ≤ f₂ → g₁ ≤ g₂ → f₁ / g₁ ≤ f₂ / g₂ := map₂_mono
@[to_additive] protected lemma div_le_div_left : g₁ ≤ g₂ → f / g₁ ≤ f / g₂ := map₂_mono_left
@[to_additive] protected lemma div_le_div_right : f₁ ≤ f₂ → f₁ / g ≤ f₂ / g := map₂_mono_right
@[simp, to_additive] protected lemma le_div_iff :
h ≤ f / g ↔ ∀ ⦃s⦄, s ∈ f → ∀ ⦃t⦄, t ∈ g → s / t ∈ h :=
le_map₂_iff
@[to_additive] instance covariant_div : covariant_class (filter α) (filter α) (/) (≤) :=
⟨λ f g h, map₂_mono_left⟩
@[to_additive] instance covariant_swap_div : covariant_class (filter α) (filter α) (swap (/)) (≤) :=
⟨λ f g h, map₂_mono_right⟩
end div
open_locale pointwise
/-- Repeated pointwise addition (not the same as pointwise repeated addition!) of a `filter`. See
Note [pointwise nat action].-/
protected def has_nsmul [has_zero α] [has_add α] : has_smul ℕ (filter α) := ⟨nsmul_rec⟩
/-- Repeated pointwise multiplication (not the same as pointwise repeated multiplication!) of a
`filter`. See Note [pointwise nat action]. -/
@[to_additive]
protected def has_npow [has_one α] [has_mul α] : has_pow (filter α) ℕ := ⟨λ s n, npow_rec n s⟩
/-- Repeated pointwise addition/subtraction (not the same as pointwise repeated
addition/subtraction!) of a `filter`. See Note [pointwise nat action]. -/
protected def has_zsmul [has_zero α] [has_add α] [has_neg α] : has_smul ℤ (filter α) :=
⟨zsmul_rec⟩
/-- Repeated pointwise multiplication/division (not the same as pointwise repeated
multiplication/division!) of a `filter`. See Note [pointwise nat action]. -/
@[to_additive] protected def has_zpow [has_one α] [has_mul α] [has_inv α] : has_pow (filter α) ℤ :=
⟨λ s n, zpow_rec n s⟩
localized "attribute [instance] filter.has_nsmul filter.has_npow filter.has_zsmul filter.has_zpow"
in pointwise
/-- `filter α` is a `semigroup` under pointwise operations if `α` is.-/
@[to_additive "`filter α` is an `add_semigroup` under pointwise operations if `α` is."]
protected def semigroup [semigroup α] : semigroup (filter α) :=
{ mul := (*),
mul_assoc := λ f g h, map₂_assoc mul_assoc }
/-- `filter α` is a `comm_semigroup` under pointwise operations if `α` is. -/
@[to_additive "`filter α` is an `add_comm_semigroup` under pointwise operations if `α` is."]
protected def comm_semigroup [comm_semigroup α] : comm_semigroup (filter α) :=
{ mul_comm := λ f g, map₂_comm mul_comm,
..filter.semigroup }
section mul_one_class
variables [mul_one_class α] [mul_one_class β]
/-- `filter α` is a `mul_one_class` under pointwise operations if `α` is. -/
@[to_additive "`filter α` is an `add_zero_class` under pointwise operations if `α` is."]
protected def mul_one_class : mul_one_class (filter α) :=
{ one := 1,
mul := (*),
one_mul := map₂_left_identity one_mul,
mul_one := map₂_right_identity mul_one }
localized "attribute [instance] filter.semigroup filter.add_semigroup filter.comm_semigroup
filter.add_comm_semigroup filter.mul_one_class filter.add_zero_class" in pointwise
/-- If `φ : α →* β` then `map_monoid_hom φ` is the monoid homomorphism
`filter α →* filter β` induced by `map φ`. -/
@[to_additive "If `φ : α →+ β` then `map_add_monoid_hom φ` is the monoid homomorphism
`filter α →+ filter β` induced by `map φ`."]
def map_monoid_hom [monoid_hom_class F α β] (φ : F) : filter α →* filter β :=
{ to_fun := map φ,
map_one' := filter.map_one φ,
map_mul' := λ _ _, filter.map_mul φ }
-- The other direction does not hold in general
@[to_additive]
lemma comap_mul_comap_le [mul_hom_class F α β] (m : F) {f g : filter β} :
f.comap m * g.comap m ≤ (f * g).comap m :=
λ s ⟨t, ⟨t₁, t₂, ht₁, ht₂, t₁t₂⟩, mt⟩,
⟨m ⁻¹' t₁, m ⁻¹' t₂, ⟨t₁, ht₁, subset.rfl⟩, ⟨t₂, ht₂, subset.rfl⟩,
(preimage_mul_preimage_subset _).trans $ (preimage_mono t₁t₂).trans mt⟩
@[to_additive]
lemma tendsto.mul_mul [mul_hom_class F α β] (m : F) {f₁ g₁ : filter α} {f₂ g₂ : filter β} :
tendsto m f₁ f₂ → tendsto m g₁ g₂ → tendsto m (f₁ * g₁) (f₂ * g₂) :=
λ hf hg, (filter.map_mul m).trans_le $ mul_le_mul' hf hg
/-- `pure` as a `monoid_hom`. -/
@[to_additive "`pure` as an `add_monoid_hom`."]
def pure_monoid_hom : α →* filter α := { ..pure_mul_hom, ..pure_one_hom }
@[simp, to_additive] lemma coe_pure_monoid_hom : (pure_monoid_hom : α → filter α) = pure := rfl
@[simp, to_additive] lemma pure_monoid_hom_apply (a : α) : pure_monoid_hom a = pure a := rfl
end mul_one_class
section monoid
variables [monoid α] {f g : filter α} {s : set α} {a : α} {m n : ℕ}
/-- `filter α` is a `monoid` under pointwise operations if `α` is. -/
@[to_additive "`filter α` is an `add_monoid` under pointwise operations if `α` is."]
protected def monoid : monoid (filter α) :=
{ ..filter.mul_one_class, ..filter.semigroup, ..filter.has_npow }
localized "attribute [instance] filter.monoid filter.add_monoid" in pointwise
@[to_additive] lemma pow_mem_pow (hs : s ∈ f) : ∀ n : ℕ, s ^ n ∈ f ^ n
| 0 := by { rw pow_zero, exact one_mem_one }
| (n + 1) := by { rw pow_succ, exact mul_mem_mul hs (pow_mem_pow _) }
@[simp, to_additive nsmul_bot] lemma bot_pow {n : ℕ} (hn : n ≠ 0) : (⊥ : filter α) ^ n = ⊥ :=
by rw [←tsub_add_cancel_of_le (nat.succ_le_of_lt $ nat.pos_of_ne_zero hn), pow_succ, bot_mul]
@[to_additive] lemma mul_top_of_one_le (hf : 1 ≤ f) : f * ⊤ = ⊤ :=
begin
refine top_le_iff.1 (λ s, _),
simp only [mem_mul, mem_top, exists_and_distrib_left, exists_eq_left],
rintro ⟨t, ht, hs⟩,
rwa [mul_univ_of_one_mem (mem_one.1 $ hf ht), univ_subset_iff] at hs,
end
@[to_additive] lemma top_mul_of_one_le (hf : 1 ≤ f) : ⊤ * f = ⊤ :=
begin
refine top_le_iff.1 (λ s, _),
simp only [mem_mul, mem_top, exists_and_distrib_left, exists_eq_left],
rintro ⟨t, ht, hs⟩,
rwa [univ_mul_of_one_mem (mem_one.1 $ hf ht), univ_subset_iff] at hs,
end
@[simp, to_additive] lemma top_mul_top : (⊤ : filter α) * ⊤ = ⊤ := mul_top_of_one_le le_top
--TODO: `to_additive` trips up on the `1 : ℕ` used in the pattern-matching.
lemma nsmul_top {α : Type*} [add_monoid α] : ∀ {n : ℕ}, n ≠ 0 → n • (⊤ : filter α) = ⊤
| 0 := λ h, (h rfl).elim
| 1 := λ _, one_nsmul _
| (n + 2) := λ _, by { rw [succ_nsmul, nsmul_top n.succ_ne_zero, top_add_top] }
@[to_additive nsmul_top] lemma top_pow : ∀ {n : ℕ}, n ≠ 0 → (⊤ : filter α) ^ n = ⊤
| 0 := λ h, (h rfl).elim
| 1 := λ _, pow_one _
| (n + 2) := λ _, by { rw [pow_succ, top_pow n.succ_ne_zero, top_mul_top] }
@[to_additive] protected lemma _root_.is_unit.filter : is_unit a → is_unit (pure a : filter α) :=
is_unit.map (pure_monoid_hom : α →* filter α)
end monoid
/-- `filter α` is a `comm_monoid` under pointwise operations if `α` is. -/
@[to_additive "`filter α` is an `add_comm_monoid` under pointwise operations if `α` is."]
protected def comm_monoid [comm_monoid α] : comm_monoid (filter α) :=
{ ..filter.mul_one_class, ..filter.comm_semigroup }
open_locale pointwise
section division_monoid
variables [division_monoid α] {f g : filter α}
@[to_additive]
protected lemma mul_eq_one_iff : f * g = 1 ↔ ∃ a b, f = pure a ∧ g = pure b ∧ a * b = 1 :=
begin
refine ⟨λ hfg, _, _⟩,
{ obtain ⟨t₁, t₂, h₁, h₂, h⟩ : (1 : set α) ∈ f * g := hfg.symm.subst one_mem_one,
have hfg : (f * g).ne_bot := hfg.symm.subst one_ne_bot,
rw [(hfg.nonempty_of_mem $ mul_mem_mul h₁ h₂).subset_one_iff, set.mul_eq_one_iff] at h,
obtain ⟨a, b, rfl, rfl, h⟩ := h,
refine ⟨a, b, _, _, h⟩,
{ rwa [←hfg.of_mul_left.le_pure_iff, le_pure_iff] },
{ rwa [←hfg.of_mul_right.le_pure_iff, le_pure_iff] } },
{ rintro ⟨a, b, rfl, rfl, h⟩,
rw [pure_mul_pure, h, pure_one] }
end
/-- `filter α` is a division monoid under pointwise operations if `α` is. -/
@[to_additive "`filter α` is a subtraction monoid under pointwise
operations if `α` is."]
protected def division_monoid : division_monoid (filter α) :=
{ mul_inv_rev := λ s t, map_map₂_antidistrib mul_inv_rev,
inv_eq_of_mul := λ s t h, begin
obtain ⟨a, b, rfl, rfl, hab⟩ := filter.mul_eq_one_iff.1 h,
rw [inv_pure, inv_eq_of_mul_eq_one_right hab],
end,
div_eq_mul_inv := λ f g, map_map₂_distrib_right div_eq_mul_inv,
..filter.monoid, ..filter.has_involutive_inv, ..filter.has_div, ..filter.has_zpow }
@[to_additive] lemma is_unit_iff : is_unit f ↔ ∃ a, f = pure a ∧ is_unit a :=
begin
split,
{ rintro ⟨u, rfl⟩,
obtain ⟨a, b, ha, hb, h⟩ := filter.mul_eq_one_iff.1 u.mul_inv,
refine ⟨a, ha, ⟨a, b, h, pure_injective _⟩, rfl⟩,
rw [←pure_mul_pure, ←ha, ←hb],
exact u.inv_mul },
{ rintro ⟨a, rfl, ha⟩,
exact ha.filter }
end
end division_monoid
/-- `filter α` is a commutative division monoid under pointwise operations if `α` is. -/
@[to_additive subtraction_comm_monoid "`filter α` is a commutative subtraction monoid under
pointwise operations if `α` is."]
protected def division_comm_monoid [division_comm_monoid α] : division_comm_monoid (filter α) :=
{ ..filter.division_monoid, ..filter.comm_semigroup }
/-- `filter α` has distributive negation if `α` has. -/
protected def has_distrib_neg [has_mul α] [has_distrib_neg α] : has_distrib_neg (filter α) :=
{ neg_mul := λ _ _, map₂_map_left_comm neg_mul,
mul_neg := λ _ _, map_map₂_right_comm mul_neg,
..filter.has_involutive_neg }
localized "attribute [instance] filter.comm_monoid filter.add_comm_monoid filter.division_monoid
filter.subtraction_monoid filter.division_comm_monoid filter.subtraction_comm_monoid
filter.has_distrib_neg" in pointwise
section distrib
variables [distrib α] {f g h : filter α}
/-!
Note that `filter α` is not a `distrib` because `f * g + f * h` has cross terms that `f * (g + h)`
lacks.
-/
lemma mul_add_subset : f * (g + h) ≤ f * g + f * h := map₂_distrib_le_left mul_add
lemma add_mul_subset : (f + g) * h ≤ f * h + g * h := map₂_distrib_le_right add_mul
end distrib
section mul_zero_class
variables [mul_zero_class α] {f g : filter α}
/-! Note that `filter` is not a `mul_zero_class` because `0 * ⊥ ≠ 0`. -/
lemma ne_bot.mul_zero_nonneg (hf : f.ne_bot) : 0 ≤ f * 0 :=
le_mul_iff.2 $ λ t₁ h₁ t₂ h₂, let ⟨a, ha⟩ := hf.nonempty_of_mem h₁ in ⟨_, _, ha, h₂, mul_zero _⟩
lemma ne_bot.zero_mul_nonneg (hg : g.ne_bot) : 0 ≤ 0 * g :=
le_mul_iff.2 $ λ t₁ h₁ t₂ h₂, let ⟨b, hb⟩ := hg.nonempty_of_mem h₂ in ⟨_, _, h₁, hb, zero_mul _⟩
end mul_zero_class
section group
variables [group α] [division_monoid β] [monoid_hom_class F α β] (m : F) {f g f₁ g₁ : filter α}
{f₂ g₂ : filter β}
/-! Note that `filter α` is not a group because `f / f ≠ 1` in general -/
@[simp, to_additive] protected lemma one_le_div_iff : 1 ≤ f / g ↔ ¬ disjoint f g :=
begin
refine ⟨λ h hfg, _, _⟩,
{ obtain ⟨s, hs, t, ht, hst⟩ := hfg.le_bot (mem_bot : ∅ ∈ ⊥),
exact set.one_mem_div_iff.1 (h $ div_mem_div hs ht) (disjoint_iff.2 hst.symm) },
{ rintro h s ⟨t₁, t₂, h₁, h₂, hs⟩,
exact hs (set.one_mem_div_iff.2 $ λ ht, h $ disjoint_of_disjoint_of_mem ht h₁ h₂) }
end
@[to_additive] lemma not_one_le_div_iff : ¬ 1 ≤ f / g ↔ disjoint f g :=
filter.one_le_div_iff.not_left
@[to_additive] lemma ne_bot.one_le_div (h : f.ne_bot) : 1 ≤ f / f :=
begin
rintro s ⟨t₁, t₂, h₁, h₂, hs⟩,
obtain ⟨a, ha₁, ha₂⟩ := set.not_disjoint_iff.1 (h.not_disjoint h₁ h₂),
rw [mem_one, ←div_self' a],
exact hs (set.div_mem_div ha₁ ha₂),
end
@[to_additive] lemma is_unit_pure (a : α) : is_unit (pure a : filter α) := (group.is_unit a).filter
@[simp] lemma is_unit_iff_singleton : is_unit f ↔ ∃ a, f = pure a :=
by simp only [is_unit_iff, group.is_unit, and_true]
include β
@[to_additive] lemma map_inv' : f⁻¹.map m = (f.map m)⁻¹ := semiconj.filter_map (map_inv m) f
@[to_additive] lemma tendsto.inv_inv : tendsto m f₁ f₂ → tendsto m f₁⁻¹ f₂⁻¹ :=
λ hf, (filter.map_inv' m).trans_le $ filter.inv_le_inv hf
@[to_additive] protected lemma map_div : (f / g).map m = f.map m / g.map m :=
map_map₂_distrib $ map_div m
@[to_additive]
lemma tendsto.div_div : tendsto m f₁ f₂ → tendsto m g₁ g₂ → tendsto m (f₁ / g₁) (f₂ / g₂) :=
λ hf hg, (filter.map_div m).trans_le $ filter.div_le_div hf hg
end group
open_locale pointwise
section group_with_zero
variables [group_with_zero α] {f g : filter α}
lemma ne_bot.div_zero_nonneg (hf : f.ne_bot) : 0 ≤ f / 0 :=
filter.le_div_iff.2 $ λ t₁ h₁ t₂ h₂, let ⟨a, ha⟩ := hf.nonempty_of_mem h₁ in
⟨_, _, ha, h₂, div_zero _⟩
lemma ne_bot.zero_div_nonneg (hg : g.ne_bot) : 0 ≤ 0 / g :=
filter.le_div_iff.2 $ λ t₁ h₁ t₂ h₂, let ⟨b, hb⟩ := hg.nonempty_of_mem h₂ in
⟨_, _, h₁, hb, zero_div _⟩
end group_with_zero
/-! ### Scalar addition/multiplication of filters -/
section smul
variables [has_smul α β] {f f₁ f₂ : filter α} {g g₁ g₂ h : filter β} {s : set α} {t : set β}
{a : α} {b : β}
/-- The filter `f • g` is generated by `{s • t | s ∈ f, t ∈ g}` in locale `pointwise`. -/
@[to_additive filter.has_vadd
"The filter `f +ᵥ g` is generated by `{s +ᵥ t | s ∈ f, t ∈ g}` in locale `pointwise`."]
protected def has_smul : has_smul (filter α) (filter β) :=
/- This is defeq to `map₂ (•) f g`, but the hypothesis unfolds to `t₁ • t₂ ⊆ s` rather than all the
way to `set.image2 (•) t₁ t₂ ⊆ s`. -/
⟨λ f g, { sets := {s | ∃ t₁ t₂, t₁ ∈ f ∧ t₂ ∈ g ∧ t₁ • t₂ ⊆ s}, ..map₂ (•) f g }⟩
localized "attribute [instance] filter.has_smul filter.has_vadd" in pointwise
@[simp, to_additive] lemma map₂_smul : map₂ (•) f g = f • g := rfl
@[to_additive] lemma mem_smul : t ∈ f • g ↔ ∃ t₁ t₂, t₁ ∈ f ∧ t₂ ∈ g ∧ t₁ • t₂ ⊆ t := iff.rfl
@[to_additive] lemma smul_mem_smul : s ∈ f → t ∈ g → s • t ∈ f • g := image2_mem_map₂
@[simp, to_additive] lemma bot_smul : (⊥ : filter α) • g = ⊥ := map₂_bot_left
@[simp, to_additive] lemma smul_bot : f • (⊥ : filter β) = ⊥ := map₂_bot_right
@[simp, to_additive] lemma smul_eq_bot_iff : f • g = ⊥ ↔ f = ⊥ ∨ g = ⊥ := map₂_eq_bot_iff
@[simp, to_additive] lemma smul_ne_bot_iff : (f • g).ne_bot ↔ f.ne_bot ∧ g.ne_bot := map₂_ne_bot_iff
@[to_additive] lemma ne_bot.smul : ne_bot f → ne_bot g → ne_bot (f • g) := ne_bot.map₂
@[to_additive] lemma ne_bot.of_smul_left : (f • g).ne_bot → f.ne_bot := ne_bot.of_map₂_left
@[to_additive] lemma ne_bot.of_smul_right : (f • g).ne_bot → g.ne_bot := ne_bot.of_map₂_right
@[simp, to_additive] lemma pure_smul : (pure a : filter α) • g = g.map ((•) a) := map₂_pure_left
@[simp, to_additive] lemma smul_pure : f • pure b = f.map (• b) := map₂_pure_right
@[simp, to_additive] lemma pure_smul_pure :
(pure a : filter α) • (pure b : filter β) = pure (a • b) := map₂_pure
@[to_additive] lemma smul_le_smul : f₁ ≤ f₂ → g₁ ≤ g₂ → f₁ • g₁ ≤ f₂ • g₂ := map₂_mono
@[to_additive] lemma smul_le_smul_left : g₁ ≤ g₂ → f • g₁ ≤ f • g₂ := map₂_mono_left
@[to_additive] lemma smul_le_smul_right : f₁ ≤ f₂ → f₁ • g ≤ f₂ • g := map₂_mono_right
@[simp, to_additive] lemma le_smul_iff : h ≤ f • g ↔ ∀ ⦃s⦄, s ∈ f → ∀ ⦃t⦄, t ∈ g → s • t ∈ h :=
le_map₂_iff
@[to_additive] instance covariant_smul : covariant_class (filter α) (filter β) (•) (≤) :=
⟨λ f g h, map₂_mono_left⟩
end smul
/-! ### Scalar subtraction of filters -/
section vsub
variables [has_vsub α β] {f f₁ f₂ g g₁ g₂ : filter β} {h : filter α} {s t : set β} {a b : β}
include α
/-- The filter `f -ᵥ g` is generated by `{s -ᵥ t | s ∈ f, t ∈ g}` in locale `pointwise`. -/
protected def has_vsub : has_vsub (filter α) (filter β) :=
/- This is defeq to `map₂ (-ᵥ) f g`, but the hypothesis unfolds to `t₁ -ᵥ t₂ ⊆ s` rather than all
the way to `set.image2 (-ᵥ) t₁ t₂ ⊆ s`. -/
⟨λ f g, { sets := {s | ∃ t₁ t₂, t₁ ∈ f ∧ t₂ ∈ g ∧ t₁ -ᵥ t₂ ⊆ s}, ..map₂ (-ᵥ) f g }⟩
localized "attribute [instance] filter.has_vsub" in pointwise
@[simp] lemma map₂_vsub : map₂ (-ᵥ) f g = f -ᵥ g := rfl
lemma mem_vsub {s : set α} : s ∈ f -ᵥ g ↔ ∃ t₁ t₂, t₁ ∈ f ∧ t₂ ∈ g ∧ t₁ -ᵥ t₂ ⊆ s := iff.rfl
lemma vsub_mem_vsub : s ∈ f → t ∈ g → s -ᵥ t ∈ f -ᵥ g := image2_mem_map₂
@[simp] lemma bot_vsub : (⊥ : filter β) -ᵥ g = ⊥ := map₂_bot_left
@[simp] lemma vsub_bot : f -ᵥ (⊥ : filter β) = ⊥ := map₂_bot_right
@[simp] lemma vsub_eq_bot_iff : f -ᵥ g = ⊥ ↔ f = ⊥ ∨ g = ⊥ := map₂_eq_bot_iff
@[simp] lemma vsub_ne_bot_iff : (f -ᵥ g : filter α).ne_bot ↔ f.ne_bot ∧ g.ne_bot := map₂_ne_bot_iff
lemma ne_bot.vsub : ne_bot f → ne_bot g → ne_bot (f -ᵥ g) := ne_bot.map₂
lemma ne_bot.of_vsub_left : (f -ᵥ g : filter α).ne_bot → f.ne_bot := ne_bot.of_map₂_left
lemma ne_bot.of_vsub_right : (f -ᵥ g : filter α).ne_bot → g.ne_bot := ne_bot.of_map₂_right
@[simp] lemma pure_vsub : (pure a : filter β) -ᵥ g = g.map ((-ᵥ) a) := map₂_pure_left
@[simp] lemma vsub_pure : f -ᵥ pure b = f.map (-ᵥ b) := map₂_pure_right
@[simp] lemma pure_vsub_pure : (pure a : filter β) -ᵥ pure b = (pure (a -ᵥ b) : filter α) :=
map₂_pure
lemma vsub_le_vsub : f₁ ≤ f₂ → g₁ ≤ g₂ → f₁ -ᵥ g₁ ≤ f₂ -ᵥ g₂ := map₂_mono
lemma vsub_le_vsub_left : g₁ ≤ g₂ → f -ᵥ g₁ ≤ f -ᵥ g₂ := map₂_mono_left
lemma vsub_le_vsub_right : f₁ ≤ f₂ → f₁ -ᵥ g ≤ f₂ -ᵥ g := map₂_mono_right
@[simp] lemma le_vsub_iff : h ≤ f -ᵥ g ↔ ∀ ⦃s⦄, s ∈ f → ∀ ⦃t⦄, t ∈ g → s -ᵥ t ∈ h := le_map₂_iff
end vsub
/-! ### Translation/scaling of filters -/
section smul
variables [has_smul α β] {f f₁ f₂ : filter β} {s : set β} {a : α}
/-- `a • f` is the map of `f` under `a •` in locale `pointwise`. -/
@[to_additive filter.has_vadd_filter
"`a +ᵥ f` is the map of `f` under `a +ᵥ` in locale `pointwise`."]
protected def has_smul_filter : has_smul α (filter β) := ⟨λ a, map ((•) a)⟩
localized "attribute [instance] filter.has_smul_filter filter.has_vadd_filter" in pointwise
@[simp, to_additive] lemma map_smul : map (λ b, a • b) f = a • f := rfl
@[to_additive] lemma mem_smul_filter : s ∈ a • f ↔ (•) a ⁻¹' s ∈ f := iff.rfl
@[to_additive] lemma smul_set_mem_smul_filter : s ∈ f → a • s ∈ a • f := image_mem_map
@[simp, to_additive] lemma smul_filter_bot : a • (⊥ : filter β) = ⊥ := map_bot
@[simp, to_additive] lemma smul_filter_eq_bot_iff : a • f = ⊥ ↔ f = ⊥ := map_eq_bot_iff
@[simp, to_additive] lemma smul_filter_ne_bot_iff : (a • f).ne_bot ↔ f.ne_bot := map_ne_bot_iff _
@[to_additive] lemma ne_bot.smul_filter : f.ne_bot → (a • f).ne_bot := λ h, h.map _
@[to_additive] lemma ne_bot.of_smul_filter : (a • f).ne_bot → f.ne_bot := ne_bot.of_map
@[to_additive] lemma smul_filter_le_smul_filter (hf : f₁ ≤ f₂) : a • f₁ ≤ a • f₂ :=
map_mono hf
@[to_additive] instance covariant_smul_filter : covariant_class α (filter β) (•) (≤) :=
⟨λ f, map_mono⟩
end smul
open_locale pointwise
@[to_additive]
instance smul_comm_class_filter [has_smul α γ] [has_smul β γ] [smul_comm_class α β γ] :
smul_comm_class α β (filter γ) :=
⟨λ _ _ _, map_comm (funext $ smul_comm _ _) _⟩
@[to_additive]
instance smul_comm_class_filter' [has_smul α γ] [has_smul β γ] [smul_comm_class α β γ] :
smul_comm_class α (filter β) (filter γ) :=
⟨λ a f g, map_map₂_distrib_right $ smul_comm a⟩
@[to_additive]
instance smul_comm_class_filter'' [has_smul α γ] [has_smul β γ] [smul_comm_class α β γ] :
smul_comm_class (filter α) β (filter γ) :=
by haveI := smul_comm_class.symm α β γ; exact smul_comm_class.symm _ _ _
@[to_additive]
instance smul_comm_class [has_smul α γ] [has_smul β γ] [smul_comm_class α β γ] :
smul_comm_class (filter α) (filter β) (filter γ) :=
⟨λ f g h, map₂_left_comm smul_comm⟩
@[to_additive]
instance is_scalar_tower [has_smul α β] [has_smul α γ] [has_smul β γ] [is_scalar_tower α β γ] :
is_scalar_tower α β (filter γ) :=
⟨λ a b f, by simp only [←map_smul, map_map, smul_assoc]⟩
@[to_additive]
instance is_scalar_tower' [has_smul α β] [has_smul α γ] [has_smul β γ] [is_scalar_tower α β γ] :
is_scalar_tower α (filter β) (filter γ) :=
⟨λ a f g, by { refine (map_map₂_distrib_left $ λ _ _, _).symm, exact (smul_assoc a _ _).symm }⟩
@[to_additive]
instance is_scalar_tower'' [has_smul α β] [has_smul α γ] [has_smul β γ] [is_scalar_tower α β γ] :
is_scalar_tower (filter α) (filter β) (filter γ) :=
⟨λ f g h, map₂_assoc smul_assoc⟩
@[to_additive] instance is_central_scalar [has_smul α β] [has_smul αᵐᵒᵖ β] [is_central_scalar α β] :
is_central_scalar α (filter β) :=
⟨λ a f, congr_arg (λ m, map m f) $ by exact funext (λ _, op_smul_eq_smul _ _)⟩
/-- A multiplicative action of a monoid `α` on a type `β` gives a multiplicative action of
`filter α` on `filter β`. -/
@[to_additive "An additive action of an additive monoid `α` on a type `β` gives an additive action
of `filter α` on `filter β`"]
protected def mul_action [monoid α] [mul_action α β] : mul_action (filter α) (filter β) :=
{ one_smul := λ f, map₂_pure_left.trans $ by simp_rw [one_smul, map_id'],
mul_smul := λ f g h, map₂_assoc mul_smul }
/-- A multiplicative action of a monoid on a type `β` gives a multiplicative action on `filter β`.
-/
@[to_additive "An additive action of an additive monoid on a type `β` gives an additive action on
`filter β`."]
protected def mul_action_filter [monoid α] [mul_action α β] : mul_action α (filter β) :=
{ mul_smul := λ a b f, by simp only [←map_smul, map_map, function.comp, ←mul_smul],
one_smul := λ f, by simp only [←map_smul, one_smul, map_id'] }
localized "attribute [instance] filter.mul_action filter.add_action filter.mul_action_filter
filter.add_action_filter" in pointwise
/-- A distributive multiplicative action of a monoid on an additive monoid `β` gives a distributive
multiplicative action on `filter β`. -/
protected def distrib_mul_action_filter [monoid α] [add_monoid β] [distrib_mul_action α β] :
distrib_mul_action α (filter β) :=
{ smul_add := λ _ _ _, map_map₂_distrib $ smul_add _,
smul_zero := λ _, (map_pure _ _).trans $ by rw [smul_zero, pure_zero] }
/-- A multiplicative action of a monoid on a monoid `β` gives a multiplicative action on `set β`. -/
protected def mul_distrib_mul_action_filter [monoid α] [monoid β] [mul_distrib_mul_action α β] :
mul_distrib_mul_action α (set β) :=
{ smul_mul := λ _ _ _, image_image2_distrib $ smul_mul' _,
smul_one := λ _, image_singleton.trans $ by rw [smul_one, singleton_one] }
localized "attribute [instance] filter.distrib_mul_action_filter
filter.mul_distrib_mul_action_filter" in pointwise
section smul_with_zero
variables [has_zero α] [has_zero β] [smul_with_zero α β] {f : filter α} {g : filter β}
/-!
Note that we have neither `smul_with_zero α (filter β)` nor `smul_with_zero (filter α) (filter β)`
because `0 * ⊥ ≠ 0`.
-/
lemma ne_bot.smul_zero_nonneg (hf : f.ne_bot) : 0 ≤ f • (0 : filter β) :=
le_smul_iff.2 $ λ t₁ h₁ t₂ h₂, let ⟨a, ha⟩ := hf.nonempty_of_mem h₁ in
⟨_, _, ha, h₂, smul_zero _⟩
lemma ne_bot.zero_smul_nonneg (hg : g.ne_bot) : 0 ≤ (0 : filter α) • g :=
le_smul_iff.2 $ λ t₁ h₁ t₂ h₂, let ⟨b, hb⟩ := hg.nonempty_of_mem h₂ in ⟨_, _, h₁, hb, zero_smul _ _⟩
lemma zero_smul_filter_nonpos : (0 : α) • g ≤ 0 :=
begin
refine λ s hs, mem_smul_filter.2 _,
convert univ_mem,
refine eq_univ_iff_forall.2 (λ a, _),
rwa [mem_preimage, zero_smul],
end
lemma zero_smul_filter (hg : g.ne_bot) : (0 : α) • g = 0 :=
zero_smul_filter_nonpos.antisymm $ le_map_iff.2 $ λ s hs, begin
simp_rw [set.image_eta, zero_smul, (hg.nonempty_of_mem hs).image_const],
exact zero_mem_zero,
end
end smul_with_zero
end filter
|
import lambda_calculus.utlc.beta.distance
import complexity.basic
/-
- Define complexity in terms of the number of β reductions
- Programs and data need to be closed,
- additionally data needs to be fully reduced such that equivalence implies equality
-/
namespace lambda_calculus
namespace utlc
namespace β
namespace encoding
structure encoded_program :=
mk :: (value: utlc) (proof: value.closed)
inductive encoding_type
| church
| scott
| compute
structure encoded_data (_: encoding_type) :=
mk :: (value: utlc) (proof: value.closed ∧ β.reduced value)
instance (et: encoding_type): has_equiv (encoded_data et) := ⟨ λ a b : encoded_data et, a.value = b.value ⟩
@[reducible, simp] def church_data := encoded_data encoding_type.church
@[reducible, simp] def scott_data := encoded_data encoding_type.scott
@[reducible, simp] def compute_data := encoded_data encoding_type.compute
local attribute [reducible] closed
def distance_model (et: encoding_type): complexity.model encoded_program (encoded_data et) ℕ :=
⟨ λ prog data cost, distance_le cost prog.value data.value,
λ prog data, ⟨ prog.value·data.value, by simp [closed, prog.proof, data.proof.left] ⟩,
λ prog x y cx cy hx hy, reduced_equiv_inj x.proof.right y.proof.right (equiv_trans (equiv_symm (equiv_of_distance_le hx)) (equiv_of_distance_le hy)),
λ prog data c₀ c₁, distance_le_mono' ⟩
@[reducible, simp] def church_model := distance_model encoding_type.church
@[reducible, simp] def scott_model := distance_model encoding_type.scott
@[reducible, simp] def compute_model := distance_model encoding_type.compute
@[simp] theorem program_is_closed (a: encoded_program):
a.value.closed := a.proof
@[simp] theorem program_is_closed_below (a: encoded_program):
∀ n, a.value.closed_below n :=
λ n, closed_below_mono' a.proof (nat.zero_le _)
@[simp] theorem program_ignores_shift (a: encoded_program) (n: ℕ):
a.value ↑¹ n = a.value := by rw [shift_of_closed a.proof]
@[simp] theorem program_ignores_substitution (a: encoded_program) (n: ℕ) (g: utlc):
has_substitution.substitution a.value n g = a.value := by rw [substitution_of_closed a.proof]
variable {et: encoding_type}
@[simp] theorem data_is_closed (a: encoded_data et):
a.value.closed := a.proof.left
@[simp] theorem data_is_closed_below (a: encoded_data et):
∀ n, a.value.closed_below n :=
λ n, closed_below_mono' a.proof.left (nat.zero_le _)
@[simp] theorem data_is_closed_below' {α: Type}
[f: complexity.has_encoding (distance_model et) α]
(a: α) : ∀ n, (f.value.encode a).value.closed_below n :=
λ n, closed_below_mono' (f.value.encode a).proof.left (nat.zero_le _)
@[simp] theorem data_is_reduced (a: encoded_data et):
reduced a.value := a.proof.right
@[simp] theorem data_is_reduced' {α: Type}
[f: complexity.has_encoding (distance_model et) α]
(a: α) : reduced (f.value.encode a).value :=
(f.value.encode a).proof.right
@[simp] theorem value_inj (a b: encoded_data et):
a ≈ b ↔ a.value = b.value := by refl
@[simp] theorem data_value_inj {α: Type}
[f: complexity.has_encoding (distance_model et) α] (a b: α):
(f.value.encode a).value = (f.value.encode b).value ↔ a = b :=
by rw [← value_inj, complexity.encoding.inj_iff]
@[simp] theorem data_ignores_shift (a: encoded_data et) (n: ℕ):
a.value ↑¹ n = a.value := by rw [shift_of_closed a.proof.left]
@[simp] theorem data_ignores_substitution (a: encoded_data et) (n: ℕ) (g: utlc):
has_substitution.substitution a.value n g = a.value := by rw [substitution_of_closed a.proof.left]
end encoding
end β
end utlc
end lambda_calculus |
(*
* Copyright 2014, NICTA
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(NICTA_GPL)
*)
theory FinalCaps
imports InfoFlow
begin
context begin interpretation Arch . (*FIXME: arch_split*)
definition cap_points_to_label where
"cap_points_to_label aag cap l \<equiv>
(\<forall> x \<in> Structures_A.obj_refs cap. (pasObjectAbs aag x = l))
\<and> (\<forall> x \<in> cap_irqs cap. (pasIRQAbs aag x = l))"
definition intra_label_cap where
"intra_label_cap aag slot s \<equiv>
(\<forall> cap. cte_wp_at (op = cap) slot s \<longrightarrow>
(cap_points_to_label aag cap (pasObjectAbs aag (fst slot))))"
definition slots_holding_overlapping_caps :: "cap \<Rightarrow> ('z::state_ext) state \<Rightarrow> cslot_ptr set"
where
"slots_holding_overlapping_caps cap s \<equiv>
{cref. \<exists>cap'. fst (get_cap cref s) = {(cap', s)} \<and>
(Structures_A.obj_refs cap \<inter> Structures_A.obj_refs cap' \<noteq> {} \<or>
cap_irqs cap \<inter> cap_irqs cap' \<noteq> {})}"
(* we introduce a new label. The name 'silc' here stands for 'safe inter-label caps',
since the domain with this label holds copies of all inter-label caps to ensure that
any others remain 'safe' by never becoming final caps, which would otherwise introduce
a potential covert storage channel *)
datatype 'a subject_label = OrdinaryLabel 'a | SilcLabel
(* we need to introduce an equivlanece on the dummy domain, and add
it to the state that the current subject can read from (i.e.
effectively add it to the current subject's domain), to complete
the proof for is_final_cap. This will necessitate showing that
the dummy domain's state is never affected, but this should be
relatively easy. The annoying part is that now we end up proving
a different property; it will take some finesse to avoid having
to do a search/replace on reads_respects \<rightarrow> reads_respects_f *)
definition silc_dom_equiv where
"silc_dom_equiv aag \<equiv>
equiv_for (\<lambda> x. pasObjectAbs aag x = SilcLabel) kheap"
(* this is an invariant that ensures that the info leak due to is_final_cap doesn't
arise. silc stands for 'safe inter label caps'.
we include a condition that the contents of SilcLabel wrt the kheap are unchanged from
soem fixed reference state, since we invariably use this fact to reason that the
invariant is preserved anyway. Including it here saves duplicating essentially identical
reasoning. *)
definition silc_inv :: "'a subject_label PAS \<Rightarrow> det_ext state \<Rightarrow> det_ext state \<Rightarrow> bool" where
"silc_inv aag st s \<equiv>
(SilcLabel \<noteq> pasSubject aag) \<and>
(\<forall> x. pasObjectAbs aag x = SilcLabel \<longrightarrow> (\<exists> sz. cap_table_at sz x s)) \<and>
(\<forall> y auth. (y,auth,SilcLabel) \<in> pasPolicy aag \<longrightarrow> y = SilcLabel) \<and>
(\<forall> slot cap. cte_wp_at (op = cap) slot s \<and>
\<not> intra_label_cap aag slot s \<longrightarrow>
(\<exists> lslot. lslot \<in> slots_holding_overlapping_caps cap s \<and>
(pasObjectAbs aag (fst lslot) = SilcLabel))) \<and>
all_children (\<lambda>x. pasObjectAbs aag (fst x) = SilcLabel) (cdt s) \<and>
silc_dom_equiv aag st s"
lemma silc_inv_exst[simp]:
"silc_inv aag st (trans_state f s) = silc_inv aag st s"
apply(auto simp: silc_inv_def intra_label_cap_def slots_holding_overlapping_caps_def silc_dom_equiv_def equiv_for_def)
done
end
lemma (in is_extended') silc_inv[wp]: "I (silc_inv aag st)" by (rule lift_inv,simp)
context begin interpretation Arch . (*FIXME: arch_split*)
lemma get_cap_cte_wp_at':
"(fst (get_cap p s) = {(r,s)}) = cte_wp_at (op = r) p s"
apply(auto simp: cte_wp_at_def)
done
lemma silc_invD:
"\<lbrakk>silc_inv aag st s;
cte_wp_at (op = cap) slot s;
\<not> intra_label_cap aag slot s\<rbrakk> \<Longrightarrow>
(\<exists> lslot. lslot \<in> slots_holding_overlapping_caps cap s \<and>
(pasObjectAbs aag (fst lslot) = SilcLabel))"
apply(clarsimp simp: silc_inv_def)
apply(drule_tac x="fst slot" in spec, drule_tac x="snd slot" in spec, fastforce)
done
lemma is_final_cap'_def4:
"is_final_cap' cap s \<equiv>
\<exists> a b. slots_holding_overlapping_caps cap s = {(a,b)}"
apply(simp add: is_final_cap'_def slots_holding_overlapping_caps_def)
done
(* I think this property is strong enough to give us a sane
confidentiality rule for is_final_cap. This is true, so long as
we include the dummy domain l in what the current subject can
read *)
lemma silc_inv:
"silc_inv aag st s \<Longrightarrow>
(\<forall> cap slot. cte_wp_at (op = cap) slot s \<and> is_final_cap' cap s \<longrightarrow> (intra_label_cap aag slot s \<or> (pasObjectAbs aag (fst slot) = SilcLabel)))"
apply clarsimp
apply(erule contrapos_np)
apply(drule (2) silc_invD)
apply(subgoal_tac "(a,b) \<in> slots_holding_overlapping_caps cap s")
apply(clarsimp simp: is_final_cap'_def4 cte_wp_at_def)
apply(auto simp: slots_holding_overlapping_caps_def cte_wp_at_def)
done
lemma cte_wp_at_pspace':
"kheap s (fst p) = kheap s' (fst p) \<Longrightarrow> cte_wp_at P p s = cte_wp_at P p s'"
apply(rule iffI)
apply(erule cte_wp_atE)
apply(auto intro: cte_wp_at_cteI dest: sym)[1]
apply(auto intro: cte_wp_at_tcbI dest: sym)[1]
apply(erule cte_wp_atE)
apply(auto intro: cte_wp_at_cteI dest: sym)[1]
apply(auto intro: cte_wp_at_tcbI dest: sym)[1]
done
lemma cte_wp_at_intra_label_cap:
"\<lbrakk>cte_wp_at (op = cap) slot s; cte_wp_at (op = cap) slot t;
intra_label_cap aag slot s\<rbrakk> \<Longrightarrow> intra_label_cap aag slot t"
apply(clarsimp simp: intra_label_cap_def)
apply(auto dest: cte_wp_at_eqD2)
done
lemma not_is_final_cap_cte_wp_at:
"\<lbrakk>\<not> is_final_cap' cap s; cte_wp_at (op = cap) slot s;
Structures_A.obj_refs cap \<noteq> {} \<or> cap_irqs cap \<noteq> {}\<rbrakk> \<Longrightarrow>
\<exists> slot'. slot' \<noteq> slot \<and> slot' \<in> slots_holding_overlapping_caps cap s"
apply(simp add: is_final_cap'_def4)
apply(subgoal_tac "slot \<in> slots_holding_overlapping_caps cap s")
apply(drule_tac x="fst slot" in spec, drule_tac x="snd slot" in spec)
apply simp
apply fastforce
apply(auto simp: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
done
lemma is_final_then_nonempty_refs:
"is_final_cap' cap s \<Longrightarrow>
Structures_A.obj_refs cap \<noteq> {} \<or> cap_irqs cap \<noteq> {}"
apply(auto simp add: is_final_cap'_def)
done
lemma caps_ref_single_objects:
"\<lbrakk>x \<in> Structures_A.obj_refs cap;
y \<in> Structures_A.obj_refs cap\<rbrakk> \<Longrightarrow>
x = y"
apply(case_tac cap)
apply(simp_all)
done
lemma caps_ref_single_irqs:
"\<lbrakk>x \<in> cap_irqs cap;
y \<in> cap_irqs cap\<rbrakk> \<Longrightarrow>
x = y"
apply(case_tac cap)
apply(simp_all)
done
lemma not_is_final_cap:
"\<lbrakk>slot' \<noteq> slot; cte_wp_at (op = cap) slot t;
cte_wp_at (op = cap') slot' t;
Structures_A.obj_refs cap \<inter> Structures_A.obj_refs cap' =
{} \<longrightarrow>
cap_irqs cap \<inter> cap_irqs cap' \<noteq> {}\<rbrakk> \<Longrightarrow>
\<not> is_final_cap' cap t"
apply(rule ccontr)
apply(clarsimp simp: is_final_cap'_def get_cap_cte_wp_at')
apply(erule_tac B="{(a,b)}" in equalityE)
apply(frule_tac c=slot in subsetD)
apply fastforce
apply(drule_tac c=slot' in subsetD)
apply fastforce
apply fastforce
done
lemma caps_ref_either_an_object_or_irq:
"ref \<in> Structures_A.obj_refs cap' \<Longrightarrow>
(cap_irqs cap' = {})"
apply(case_tac cap', simp_all)
done
lemma caps_ref_either_an_object_or_irq':
"ref \<in> cap_irqs cap' \<Longrightarrow>
(Structures_A.obj_refs cap' = {})"
apply(case_tac cap', simp_all)
done
definition reads_equiv_f where
"reads_equiv_f aag s s' \<equiv> reads_equiv aag s s' \<and> silc_dom_equiv aag s s'"
abbreviation reads_respects_f where
"reads_respects_f aag l P f \<equiv> equiv_valid_inv (reads_equiv_f aag) (affects_equiv aag l) P f"
lemma intra_label_capD:
"\<lbrakk>intra_label_cap aag slot s;
cte_wp_at (op = cap) slot s\<rbrakk> \<Longrightarrow>
(cap_points_to_label aag cap (pasObjectAbs aag (fst slot)))"
by(auto simp: intra_label_cap_def)
lemma is_subject_kheap_eq:
"\<lbrakk>reads_equiv aag s t; is_subject aag ptr\<rbrakk> \<Longrightarrow> kheap s ptr = kheap t ptr"
apply(clarsimp simp: reads_equiv_def2)
apply(erule states_equiv_forE_kheap)
apply(blast intro: aag_can_read_self)
done
lemma is_final_cap_reads_respects_helper:
"\<lbrakk>silc_inv aag st s; cte_wp_at (op = cap) slot s;
silc_inv aag st t; cte_wp_at (op = cap) slot t;
is_subject aag (fst slot); reads_equiv aag s t;
silc_dom_equiv aag s t; affects_equiv aag l s t;
kheap s (fst slot) = kheap t (fst slot);
cte_wp_at (op = cap) slot s =
cte_wp_at (op = cap) slot t;
is_final_cap' cap s\<rbrakk>
\<Longrightarrow> is_final_cap' cap t"
apply(frule_tac s=s in silc_inv)
apply(drule_tac x=cap in spec, drule_tac x="slot" in spec, simp)
apply(erule disjE)
prefer 2
apply(simp add: silc_inv_def)
apply(frule_tac s=s and t=t in cte_wp_at_intra_label_cap, assumption+)
apply(rule ccontr)
apply(drule not_is_final_cap_cte_wp_at)
apply assumption
apply(erule is_final_then_nonempty_refs)
apply(elim exE conjE, rename_tac slot')
apply(simp add: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
apply(elim exE conjE, rename_tac cap')
apply(case_tac "is_subject aag (fst slot')")
(* this case is easy, since the new cap in question must also exist
in s too, and so the original cap in s is not final, creating
a clear contradiction *)
apply(drule_tac ptr="fst slot'" in is_subject_kheap_eq, assumption)
apply(cut_tac p="slot'"and s=s and s'=t and P="op = cap'" in cte_wp_at_pspace', assumption)
apply(subgoal_tac "\<not> is_final_cap' cap s")
apply blast
apply(rule not_is_final_cap)
apply assumption
apply assumption
apply simp
apply assumption
(* on the other hand, the new cap in t is now clearly not
intra_label. So SilcLabel must have an overlapping cap.
This overlapping cap will overlap the original one,
since caps reference only a single object. It will be
present in s as well, and so the original one won't be final;
this creates a clear contradiction *)
apply(subgoal_tac "\<not> intra_label_cap aag slot' t")
apply(drule_tac s=t and cap=cap' and slot=slot' in silc_invD)
apply assumption
apply assumption
apply(erule exE, rename_tac lslot)
apply(erule conjE)
apply(simp add: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
apply(elim exE conjE, rename_tac lcap)
apply(subgoal_tac "\<not> is_final_cap' cap s")
apply blast
apply(rule_tac slot=slot and slot'=lslot in not_is_final_cap)
apply(fastforce simp: silc_inv_def)
apply assumption
apply(rule_tac s1=t in cte_wp_at_pspace'[THEN iffD1])
apply(fastforce simp: silc_dom_equiv_def elim: equiv_forE)
apply assumption
apply(simp add: intra_label_cap_def)
apply(elim exE conjE)
apply(drule (1) cte_wp_at_eqD2, simp)
apply(simp add: cap_points_to_label_def)
apply(erule disjE)
apply(erule bexE, rename_tac ref)
apply(frule caps_ref_either_an_object_or_irq)
apply(subgoal_tac "ref \<in> Structures_A.obj_refs cap \<and> ref \<in> Structures_A.obj_refs lcap")
apply blast
apply(blast dest: caps_ref_single_objects)
apply(erule bexE, rename_tac ref)
apply(frule caps_ref_either_an_object_or_irq')
apply(subgoal_tac "ref \<in> cap_irqs cap \<and> ref \<in> cap_irqs lcap")
apply blast
apply(blast dest: caps_ref_single_irqs)
(* we have to show that cap' at slot' is not intra_label.
If it were intra_label, then it would exist in s too.
And so cap would not be final, creating a contradiction *)
apply(rule notI)
apply(drule_tac s=t and slot=slot' in intra_label_capD)
apply assumption
apply(simp add: cap_points_to_label_def)
apply(subgoal_tac "is_subject aag (fst slot')")
apply(subgoal_tac "\<not> is_final_cap' cap s", blast)
apply(rule_tac slot=slot and slot'=slot' in not_is_final_cap)
apply assumption
apply assumption
apply(rule_tac s1=t in cte_wp_at_pspace'[THEN iffD1])
apply(rule sym)
apply(fastforce elim: is_subject_kheap_eq)
apply assumption
apply assumption
apply(case_tac "\<exists> ref. ref \<in> Structures_A.obj_refs cap'")
apply(erule exE, frule caps_ref_either_an_object_or_irq)
apply(elim conjE)
apply(drule_tac x=ref in bspec, assumption)
apply(drule_tac s=t in intra_label_capD)
apply assumption
apply(simp add: cap_points_to_label_def)
apply(erule conjE, drule_tac x=ref in bspec)
apply(blast dest: caps_ref_single_objects)
apply fastforce
apply(subgoal_tac "\<exists> ref. ref \<in> cap_irqs cap'")
apply clarsimp
apply(drule_tac x=ref in bspec, assumption)
apply(drule_tac s=t in intra_label_capD)
apply assumption
apply(simp add: cap_points_to_label_def)
apply(erule conjE, drule_tac x=ref in bspec)
apply(blast dest: caps_ref_single_irqs)
apply fastforce
apply blast
done
lemma is_final_cap_reads_respects:
"reads_respects_f aag l (silc_inv aag st and ( \<lambda> s. cte_wp_at (op = cap) slot s \<and> is_subject aag (fst slot))) (is_final_cap cap)"
unfolding is_final_cap_def
apply(clarsimp simp: equiv_valid_def2 equiv_valid_2_def in_monad reads_equiv_f_def)
apply(frule (1) is_subject_kheap_eq)
apply(cut_tac p="slot" and s=s and s'=t and P="op = cap" in cte_wp_at_pspace', simp)
apply(rule iffI)
apply(blast intro: is_final_cap_reads_respects_helper)
apply(rule_tac s=t and t=s in is_final_cap_reads_respects_helper,
(simp add: silc_dom_equiv_def
|erule reads_equiv_sym
|erule affects_equiv_sym
|erule equiv_for_sym)+)
done
definition ctes_wp_at where
"ctes_wp_at P s \<equiv> {ptr. cte_wp_at P ptr s}"
lemma slots_holding_overlapping_caps_def2:
"slots_holding_overlapping_caps cap s = ctes_wp_at (\<lambda> c. (Structures_A.obj_refs cap \<inter> Structures_A.obj_refs c \<noteq> {}) \<or> (cap_irqs cap \<inter> cap_irqs c \<noteq> {})) s"
apply(simp add: slots_holding_overlapping_caps_def ctes_wp_at_def cte_wp_at_def)
done
lemma intra_label_cap_pres:
assumes cte: "\<And> P. \<lbrace>\<lambda> s. \<not> (cte_wp_at P slot s)\<rbrace> f \<lbrace>\<lambda> _ s. \<not> (cte_wp_at P slot s)\<rbrace>"
shows "\<lbrace>\<lambda> s. (intra_label_cap aag slot s) \<rbrace> f \<lbrace>\<lambda> _s. (intra_label_cap aag slot s) \<rbrace>"
apply(clarsimp simp: valid_def intra_label_cap_def)
apply(drule_tac x=cap in spec)
apply(case_tac "cte_wp_at (op = cap) slot s")
apply blast
apply(drule_tac use_valid[OF _ cte])
apply assumption
apply blast
done
lemma not_intra_label_cap_pres:
assumes cte: "\<And>P. \<lbrace>\<lambda> s. (cte_wp_at P slot s)\<rbrace> f \<lbrace>\<lambda> _ s. (cte_wp_at P slot s)\<rbrace>"
shows "\<lbrace>\<lambda> s. \<not> (intra_label_cap aag slot s) \<rbrace> f \<lbrace>\<lambda> _s. \<not> (intra_label_cap aag slot s) \<rbrace>"
apply(clarsimp simp: valid_def intra_label_cap_def)
apply(rule_tac x=cap in exI)
apply(drule_tac use_valid[OF _ cte], assumption)
apply blast
done
lemma cte_wp_at_pres_from_kheap':
assumes l: "\<And> ptr P. \<lbrace> R and (\<lambda> s. P (kheap s ptr)) and K (pasObjectAbs aag ptr = l)\<rbrace> f \<lbrace>\<lambda> _ s. P (kheap s ptr)\<rbrace>"
shows "\<lbrace>( \<lambda> s. Q (cte_wp_at P slot s)) and R and K (pasObjectAbs aag (fst slot) = l)\<rbrace> f \<lbrace>( \<lambda> _ s. Q (cte_wp_at P slot s))\<rbrace>"
apply(rule hoare_gen_asm)
apply(simp add: valid_def | intro allI impI ballI)+
apply(rename_tac x, case_tac x, simp, rename_tac rv s')
apply(subgoal_tac "\<exists> x. kheap s (fst slot) = x")
apply(erule exE, rename_tac x)
apply(drule use_valid)
apply(rule_tac ptr="fst slot" and P="\<lambda> y. y = x" in l)
apply simp
apply(drule trans, erule sym)
apply(drule_tac P=P in cte_wp_at_pspace')
apply simp
apply blast
done
lemmas cte_wp_at_pres_from_kheap = cte_wp_at_pres_from_kheap'[where R="\<top>", simplified]
lemma hoare_contrapositive:
"\<lbrakk>\<lbrace> P \<rbrace> f \<lbrace> Q \<rbrace>; \<not> Q r s'; (r, s') \<in> fst (f s)\<rbrakk> \<Longrightarrow>
\<not> P s"
apply(case_tac "P s")
apply(blast dest: use_valid)
apply assumption
done
lemma allI': "\<forall>x y. P x y \<Longrightarrow> \<forall> y x. P x y"
by simp
lemma silc_inv_pres:
assumes l: "\<And> ptr P. \<lbrace> silc_inv aag st and (\<lambda> s. P (kheap s ptr)) and K (pasObjectAbs aag ptr = SilcLabel)\<rbrace> f \<lbrace>\<lambda> _ s. P (kheap s ptr)\<rbrace>"
assumes c: "\<And>P. \<lbrace>\<lambda>s. P (cdt s) \<rbrace> f \<lbrace>\<lambda> _ s. P (cdt s)\<rbrace>"
assumes ncte: "\<And> P slot. \<lbrace> \<lambda> s. \<not> (cte_wp_at P slot s) \<rbrace> f \<lbrace> \<lambda> _ s. \<not> (cte_wp_at P slot s) \<rbrace>"
shows
"\<lbrace> silc_inv aag st \<rbrace> f \<lbrace> \<lambda>_. silc_inv aag st\<rbrace>"
apply(clarsimp simp: valid_def silc_inv_def)
apply(clarsimp simp: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
apply(rule conjI)
apply(intro allI impI)
apply(frule_tac x=x in spec, erule (1) impE)
apply(erule exE, rename_tac sz, rule_tac x=sz in exI)
apply(simp add: obj_at_def)
apply(elim exE conjE, rename_tac ko)
apply(rule_tac x=ko in exI, simp)
apply(erule use_valid[OF _ l])
apply simp
apply(clarsimp simp: silc_inv_def obj_at_def slots_holding_overlapping_caps_def2 ctes_wp_at_def)
apply(rule conjI)
apply clarsimp
apply(frule_tac x=aa in spec, drule_tac x=ba in spec, drule_tac x=cap in spec)
apply(subgoal_tac "cte_wp_at (op = cap) (aa, ba) s \<and> \<not> intra_label_cap aag (aa,ba) s")
apply(erule (1) impE)
apply (elim exE conjE)+
apply (rule_tac x=ab in exI, rule conjI, rule_tac x=bb in exI)
apply (erule use_valid[OF _ cte_wp_at_pres_from_kheap'[where R="silc_inv aag st"]])
apply(rule l)
apply simp
apply(clarsimp simp: silc_inv_def tcb_at_typ obj_at_def slots_holding_overlapping_caps_def2 ctes_wp_at_def)
apply assumption
apply(rule conjI)
apply(erule (1) hoare_contrapositive[OF ncte, simplified])
apply(rule hoare_contrapositive[OF intra_label_cap_pres, simplified, OF ncte], assumption+)
apply (rule conjI)
apply (erule use_valid[OF _ c])
apply simp
apply(simp add: silc_dom_equiv_def)
apply(rule equiv_forI)
apply(erule use_valid[OF _ l])
apply(fastforce simp: silc_inv_def obj_at_def slots_holding_overlapping_caps_def2 ctes_wp_at_def silc_dom_equiv_def elim: equiv_forE)
done
(* if we don't touch any caps or modify any object-types, then
silc_inv is preserved *)
lemma silc_inv_triv:
assumes kheap: "\<And> P x. \<lbrace>\<lambda> s. P (kheap s x) \<rbrace> f \<lbrace> \<lambda>_ s. P (kheap s x) \<rbrace>"
assumes c: "\<And>P. \<lbrace>\<lambda>s. P (cdt s) \<rbrace> f \<lbrace>\<lambda> _ s. P (cdt s)\<rbrace>"
assumes cte: "\<And> Q P cap slot. \<lbrace>\<lambda> s. Q (cte_wp_at P slot s)\<rbrace> f \<lbrace>\<lambda> _ s. Q (cte_wp_at P slot s)\<rbrace>"
assumes typ_at: "\<And> P T p. \<lbrace> \<lambda> s. P (typ_at T p s) \<rbrace> f \<lbrace> \<lambda> _ s. P (typ_at T p s) \<rbrace>"
shows
"\<lbrace> silc_inv aag st \<rbrace> f \<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
apply(clarsimp simp: valid_def silc_inv_def)
apply(rule conjI)
apply(intro allI impI)
apply(erule use_valid)
apply(rule hoare_vcg_ex_lift)
apply(rule cap_table_at_lift_valid[OF typ_at])
apply blast
apply(rule conjI)
apply(clarsimp simp: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
apply(drule_tac x=aa in spec, drule_tac x=ba in spec, drule_tac x=cap in spec)
apply(subgoal_tac "cte_wp_at (op = cap) (aa, ba) s \<and> \<not> intra_label_cap aag (aa,ba) s")
apply(elim exE conjE | simp)+
apply (rule_tac x=ab in exI, rule conjI, rule_tac x=bb in exI)
apply (erule (1) use_valid[OF _ cte])
apply(assumption)
apply(rule conjI)
apply(case_tac "cte_wp_at (op = cap) (aa, ba) s")
apply assumption
apply(drule use_valid[OF _ cte[where Q="\<lambda> x. \<not> x"]])
apply assumption
apply blast
apply(case_tac "intra_label_cap aag (aa, ba) s")
apply(drule_tac use_valid[OF _ intra_label_cap_pres[OF cte]])
apply assumption
apply blast
apply assumption
apply(simp add: silc_dom_equiv_def)
apply (rule conjI)
apply (erule use_valid[OF _ c])
apply simp
apply(rule equiv_forI)
apply(erule use_valid[OF _ kheap])
apply(fastforce elim: equiv_forE)
done
lemma set_object_wp:
"\<lbrace> \<lambda> s. P (s\<lparr>kheap := kheap s(ptr \<mapsto> obj)\<rparr>) \<rbrace>
set_object ptr obj
\<lbrace> \<lambda>_. P \<rbrace>"
unfolding set_object_def
apply (wp)
done
lemma set_cap_well_formed_cnode_helper:
"\<lbrakk>well_formed_cnode_n x xa; xa (snd slot) = Some y\<rbrakk> \<Longrightarrow>
well_formed_cnode_n x
(\<lambda>a. if a = snd slot then Some cap else xa a)"
apply(simp add: well_formed_cnode_n_def)
apply(rule equalityI)
apply(drule equalityD1)
apply(fastforce dest: subsetD split: if_splits)
apply(drule equalityD2)
apply(fastforce dest: subsetD split: if_splits)
done
lemma set_cap_slots_holding_overlapping_caps_helper:
"\<lbrakk>x \<in> slots_holding_overlapping_caps cap s; fst x \<noteq> fst slot;
ko_at (TCB tcb) (fst slot) s;
Structures_A.obj_refs cap = {} \<longrightarrow> cap_irqs cap \<noteq> {};
tcb_cap_cases (snd slot) = Some (getF, setF, blah)\<rbrakk>
\<Longrightarrow> x \<in> slots_holding_overlapping_caps cap
(s\<lparr>kheap := kheap s(fst slot \<mapsto>
TCB (setF (\<lambda> x. capa) tcb))\<rparr>)"
apply(clarsimp simp: slots_holding_overlapping_caps_def)
apply(rule_tac x=cap' in exI)
apply(clarsimp simp: get_cap_cte_wp_at')
apply(erule (1) upd_other_cte_wp_at)
done
lemma set_cap_slots_holding_overlapping_caps_other:
"\<lbrace> \<lambda> s. x \<in> slots_holding_overlapping_caps capa s \<and> pasObjectAbs aag (fst x) \<noteq> pasObjectAbs aag (fst slot) \<rbrace>
set_cap cap slot
\<lbrace> \<lambda> rv s. x \<in> slots_holding_overlapping_caps capa s \<rbrace>"
unfolding set_cap_def
apply (wp set_object_wp get_object_wp | wpc | simp add: split_def)+
apply clarsimp
apply(case_tac "Structures_A.obj_refs capa = {} \<and> cap_irqs capa = {}")
apply(clarsimp simp: slots_holding_overlapping_caps_def)
apply(subgoal_tac "fst x \<noteq> fst slot")
apply(intro allI impI conjI)
apply(clarsimp simp: slots_holding_overlapping_caps_def)
apply(rule_tac x=cap' in exI)
apply clarsimp
apply(subst get_cap_cte_wp_at')
apply(rule upd_other_cte_wp_at)
apply(simp add: cte_wp_at_def)
apply assumption
apply(auto intro: set_cap_slots_holding_overlapping_caps_helper)
done
lemma set_cap_cte_wp_at_triv:
"\<lbrace>\<top>\<rbrace> set_cap cap slot
\<lbrace>\<lambda>_. cte_wp_at (op = cap) slot\<rbrace>"
unfolding set_cap_def
apply (wp set_object_wp get_object_wp | wpc | simp add: split_def)+
apply clarsimp
apply(intro impI conjI allI)
apply(rule cte_wp_at_cteI)
apply fastforce
apply clarsimp
apply(erule (1) set_cap_well_formed_cnode_helper)
apply simp
apply(rule refl)
apply(fastforce intro: cte_wp_at_tcbI simp: tcb_cap_cases_def)+
done
lemma set_cap_neg_cte_wp_at_other_helper':
"\<lbrakk>oslot \<noteq> slot;
ko_at (TCB x) (fst oslot) s;
tcb_cap_cases (snd oslot) = Some (ogetF, osetF, orestr);
kheap
(s\<lparr>kheap := kheap s(fst oslot \<mapsto>
TCB (osetF (\<lambda> x. cap) x))\<rparr>)
(fst slot) =
Some (TCB tcb);
tcb_cap_cases (snd slot) = Some (getF, setF, restr);
P (getF tcb)\<rbrakk> \<Longrightarrow>
cte_wp_at P slot s"
apply(case_tac "fst oslot = fst slot")
apply(rule cte_wp_at_tcbI)
apply(fastforce split: if_splits simp: obj_at_def)
apply assumption
apply(fastforce split: if_splits simp: tcb_cap_cases_def dest: prod_eqI)
apply(rule cte_wp_at_tcbI)
apply(fastforce split: if_splits simp: obj_at_def)
apply assumption
apply assumption
done
lemma set_cap_neg_cte_wp_at_other_helper:
"\<lbrakk>\<not> cte_wp_at P slot s; oslot \<noteq> slot; ko_at (TCB x) (fst oslot) s;
tcb_cap_cases (snd oslot) = Some (getF, setF, restr)\<rbrakk> \<Longrightarrow>
\<not> cte_wp_at P slot (s\<lparr>kheap := kheap s(fst oslot \<mapsto> TCB (setF (\<lambda> x. cap) x))\<rparr>)"
apply(rule notI)
apply(erule cte_wp_atE)
apply(fastforce elim: notE intro: cte_wp_at_cteI split: if_splits)
apply(fastforce elim: notE intro: set_cap_neg_cte_wp_at_other_helper')
done
lemma set_cap_neg_cte_wp_at_other:
"oslot \<noteq> slot \<Longrightarrow> \<lbrace> \<lambda> s. \<not> (cte_wp_at P slot s)\<rbrace> set_cap cap oslot \<lbrace> \<lambda>rv s. \<not> (cte_wp_at P slot s) \<rbrace>"
apply(rule hoare_pre)
unfolding set_cap_def
apply(wp set_object_wp get_object_wp | wpc | simp add: split_def)+
apply(intro allI impI conjI)
apply(rule notI)
apply(erule cte_wp_atE)
apply (fastforce split: if_splits dest: prod_eqI elim: notE intro: cte_wp_at_cteI simp: obj_at_def)
apply(fastforce split: if_splits elim: notE intro: cte_wp_at_tcbI)
apply(auto dest: set_cap_neg_cte_wp_at_other_helper)
done
lemma set_cap_silc_inv:
"\<lbrace> (\<lambda> s. \<not> cap_points_to_label aag cap (pasObjectAbs aag (fst slot)) \<longrightarrow>
(\<exists> lslot. lslot \<in> slots_holding_overlapping_caps cap s \<and>
pasObjectAbs aag (fst lslot) = SilcLabel)) and silc_inv aag st and K (pasObjectAbs aag (fst slot) \<noteq> SilcLabel)\<rbrace>
set_cap cap slot
\<lbrace> \<lambda> rv. silc_inv aag st \<rbrace>"
apply(rule hoare_gen_asm)
apply(clarsimp simp: valid_def silc_inv_def)
apply(intro conjI impI allI)
apply(erule use_valid)
apply(rule hoare_vcg_ex_lift)
apply(rule cap_table_at_lift_valid[OF set_cap_typ_at])
apply blast
apply(case_tac "slot = (a,ba)")
apply(subgoal_tac "cap = capa")
apply (simp)
apply(erule impE)
apply(simp add: intra_label_cap_def)
apply(elim conjE exE)
apply(blast dest: cte_wp_at_eqD2)
apply(elim exE conjE)
apply(rule_tac x=aa in exI, simp)
apply(rule_tac x=bb in exI)
apply(erule use_valid[OF _ set_cap_slots_holding_overlapping_caps_other[where aag=aag]])
apply fastforce
apply(rule cte_wp_at_eqD2)
apply blast
apply(drule_tac s=slot in sym, simp)
apply(erule use_valid[OF _ set_cap_cte_wp_at_triv], rule TrueI)
apply(drule_tac x=a in spec, drule_tac x=ba in spec, drule_tac x= capa in spec)
apply(erule impE, rule conjI)
apply(fastforce elim!: hoare_contrapositive[OF set_cap_neg_cte_wp_at_other, simplified])
apply(rule_tac P="\<lambda> s. intra_label_cap aag (a, ba) s" in hoare_contrapositive)
apply(rule intra_label_cap_pres)
apply(erule set_cap_neg_cte_wp_at_other)
apply(erule conjE, assumption)
apply assumption
apply clarsimp
apply(rule_tac x=aa in exI, simp)
apply(rule_tac x=bb in exI)
apply(erule use_valid[OF _ set_cap_slots_holding_overlapping_caps_other[where aag=aag]])
apply fastforce
apply (erule use_valid[OF _ set_cap_mdb_inv],simp)
apply(simp add: silc_dom_equiv_def)
apply(rule equiv_forI)
apply(erule use_valid)
unfolding set_cap_def
apply(wp set_object_wp get_object_wp static_imp_wp | simp add: split_def | wpc)+
apply clarsimp
apply(rule conjI)
apply fastforce
apply (fastforce elim: equiv_forE)
done
lemma weak_derived_overlaps':
"\<lbrakk>weak_derived cap cap';
Structures_A.obj_refs cap \<noteq> {} \<or> cap_irqs cap \<noteq> {}\<rbrakk> \<Longrightarrow>
Structures_A.obj_refs cap \<inter> Structures_A.obj_refs cap' \<noteq> {} \<or>
cap_irqs cap \<inter> cap_irqs cap' \<noteq> {}"
apply(simp add: weak_derived_def)
apply(erule disjE)
prefer 2
apply simp
apply(simp add: copy_of_def split: if_split_asm add: same_object_as_def split: cap.splits)
apply((case_tac cap; simp)+)[5]
subgoal for arch1 arch2 by (cases arch1; cases arch2; simp)
done
lemma weak_derived_overlaps:
"\<lbrakk>cte_wp_at (weak_derived cap) slot s;
Structures_A.obj_refs cap \<noteq> {} \<or> cap_irqs cap \<noteq> {}\<rbrakk> \<Longrightarrow>
slot \<in> slots_holding_overlapping_caps cap s"
apply(simp add: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
apply(drule cte_wp_at_eqD)
apply(erule exE, rename_tac cap')
apply(rule_tac x=cap' in exI)
apply(blast dest: weak_derived_overlaps')
done
lemma not_cap_points_to_label_transfers_across_overlapping_caps:
"\<lbrakk>\<not> cap_points_to_label aag cap (pasObjectAbs aag (fst slot));
slot \<in> slots_holding_overlapping_caps cap s\<rbrakk>
\<Longrightarrow> \<not> intra_label_cap aag slot s"
apply(simp add: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
apply(elim exE conjE, rename_tac cap')
apply(simp add: intra_label_cap_def)
apply(rule_tac x=cap' in exI)
apply(auto simp: cap_points_to_label_def dest: caps_ref_single_objects caps_ref_single_irqs caps_ref_either_an_object_or_irq)
done
lemma overlapping_transfers_across_overlapping_caps:
"\<lbrakk>slot \<in> FinalCaps.slots_holding_overlapping_caps cap s;
cte_wp_at (op = cap') slot s;
lslot \<in> FinalCaps.slots_holding_overlapping_caps cap' s\<rbrakk> \<Longrightarrow>
lslot \<in> FinalCaps.slots_holding_overlapping_caps cap s"
apply(simp add: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
apply(elim exE conjE)
apply(drule (1) cte_wp_at_eqD2)+
apply clarsimp
apply(rename_tac lcap)
apply(rule_tac x=lcap in exI)
apply(auto dest: caps_ref_single_objects caps_ref_single_irqs caps_ref_either_an_object_or_irq)
done
lemma slots_holding_overlapping_caps_hold_caps:
"slot \<in> slots_holding_overlapping_caps cap s \<Longrightarrow>
\<exists> cap'. cte_wp_at (op = cap') slot s"
apply(fastforce simp: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
done
lemma overlapping_slots_have_labelled_overlapping_caps:
"\<lbrakk>slot \<in> slots_holding_overlapping_caps cap s; silc_inv aag st s;
\<not> cap_points_to_label aag cap (pasObjectAbs aag (fst slot))\<rbrakk> \<Longrightarrow>
(\<exists> lslot. lslot \<in> slots_holding_overlapping_caps cap s \<and>
pasObjectAbs aag (fst lslot) = SilcLabel)"
apply(drule not_cap_points_to_label_transfers_across_overlapping_caps)
apply assumption
apply(frule slots_holding_overlapping_caps_hold_caps)
apply(erule exE, rename_tac cap')
apply(drule silc_invD)
apply assumption
apply assumption
apply(blast dest: overlapping_transfers_across_overlapping_caps)
done
crunch silc_inv[wp]: set_original "silc_inv aag st"
(wp: silc_inv_triv)
(*
crunch silc_inv[wp]: set_cdt "silc_inv aag st"
(wp: silc_inv_triv)
*)
lemma nonempty_refs:
"\<not> cap_points_to_label aag cap l \<Longrightarrow> Structures_A.obj_refs cap \<noteq> {} \<or> cap_irqs cap \<noteq> {}"
apply(simp add: cap_points_to_label_def)
apply auto
done
lemma set_cdt_silc_inv: "\<lbrace>silc_inv aag st and K(all_children (\<lambda>x. pasObjectAbs aag (fst x) = SilcLabel) m)\<rbrace> set_cdt m \<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply (simp add: set_cdt_def)
apply wp
apply (simp add: silc_inv_def intra_label_cap_def slots_holding_overlapping_caps_def silc_dom_equiv_def equiv_for_def)
done
lemma update_cdt_silc_inv: "\<lbrace>silc_inv aag st and (\<lambda>s. all_children (\<lambda>x. pasObjectAbs aag (fst x) = SilcLabel) (f (cdt s)))\<rbrace> update_cdt f \<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply (simp add: update_cdt_def)
apply (wp set_cdt_silc_inv | simp)+
done
lemma silc_inv_all_children: "silc_inv aag st s \<Longrightarrow> all_children (\<lambda>x. pasObjectAbs aag (fst x) = SilcLabel) (cdt s)"
apply (simp add: silc_inv_def)
done
lemma cap_swap_silc_inv:
"\<lbrace> silc_inv aag st and cte_wp_at (weak_derived cap) slot and
cte_wp_at (weak_derived cap') slot' and K (pasObjectAbs aag (fst slot) = pasObjectAbs aag (fst slot') \<and> pasObjectAbs aag (fst slot') \<noteq> SilcLabel) \<rbrace>
cap_swap cap slot cap' slot'
\<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
apply(rule hoare_gen_asm)
unfolding cap_swap_def
apply(rule hoare_pre)
apply (wp set_cap_silc_inv hoare_vcg_ex_lift set_cap_slots_holding_overlapping_caps_other[where aag=aag] set_cdt_silc_inv static_imp_wp | simp split del: if_split)+
apply(rule conjI)
apply(rule impI, elim conjE)
apply(drule weak_derived_overlaps)
apply(erule nonempty_refs)
apply(drule overlapping_slots_have_labelled_overlapping_caps)
apply assumption
apply simp
apply fastforce
apply (rule conjI)
apply(rule impI, elim conjE)
apply(drule weak_derived_overlaps, erule nonempty_refs)
apply(drule overlapping_slots_have_labelled_overlapping_caps)
apply assumption
apply simp
apply fastforce
apply (elim conjE)
apply (drule silc_inv_all_children)
apply simp
apply (intro impI conjI)
apply (fastforce simp: all_children_def simp del: split_paired_All | simp add: all_children_def del: split_paired_All)+ (*slow*)
done
lemma cap_move_silc_inv:
"\<lbrace> silc_inv aag st and cte_wp_at (weak_derived cap) slot and
K (pasObjectAbs aag (fst slot) = pasObjectAbs aag (fst slot') \<and> pasObjectAbs aag (fst slot') \<noteq> SilcLabel) \<rbrace>
cap_move cap slot slot'
\<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
apply(rule hoare_gen_asm)
unfolding cap_move_def
apply(rule hoare_pre)
apply (wp set_cap_silc_inv hoare_vcg_ex_lift set_cap_slots_holding_overlapping_caps_other[where aag=aag] set_cdt_silc_inv static_imp_wp | simp)+
apply(rule conjI)
apply(fastforce simp: cap_points_to_label_def)
apply (rule conjI)
apply(rule impI, elim conjE)
apply(drule weak_derived_overlaps)
apply(erule nonempty_refs)
apply(drule overlapping_slots_have_labelled_overlapping_caps)
apply assumption
apply simp
apply fastforce
apply (elim conjE)
apply (drule silc_inv_all_children)
apply (fastforce simp: all_children_def simp del: split_paired_All)
done
lemma cap_irqs_max_free_index_update[simp]:
"cap_irqs (max_free_index_update cap) = cap_irqs cap"
apply(case_tac cap, simp_all add: free_index_update_def)
done
lemma cap_points_to_label_max_free_index_update[simp]:
"cap_points_to_label aag (max_free_index_update cap) l = cap_points_to_label aag cap l"
apply(simp add: cap_points_to_label_def)
done
lemma slots_holding_overlapping_caps_max_free_index_update[simp]:
"slots_holding_overlapping_caps (max_free_index_update cap) s = slots_holding_overlapping_caps cap s"
apply(simp add: slots_holding_overlapping_caps_def)
done
crunch silc_inv': set_untyped_cap_as_full "silc_inv aag st"
(wp: set_cap_silc_inv)
lemmas set_untyped_cap_as_full_silc_inv[wp] = set_untyped_cap_as_full_silc_inv'[simplified]
lemma set_untyped_cap_as_full_slots_holding_overlapping_caps_other:
"\<lbrace> \<lambda> s. x \<in> slots_holding_overlapping_caps capa s \<and> pasObjectAbs aag (fst x) \<noteq> pasObjectAbs aag (fst slot) \<rbrace>
set_untyped_cap_as_full src_cap cap slot
\<lbrace> \<lambda> rv s. x \<in> slots_holding_overlapping_caps capa s \<rbrace>"
unfolding set_untyped_cap_as_full_def
apply(rule hoare_pre)
apply(wp set_cap_slots_holding_overlapping_caps_other[where aag=aag])
apply clarsimp
done
lemma is_derived_overlaps':
"\<lbrakk>is_derived (cdt s) slot cap cap';
(Structures_A.obj_refs cap' \<noteq> {} \<or> cap_irqs cap' \<noteq> {}) \<or>
(Structures_A.obj_refs cap \<noteq> {} \<or> cap_irqs cap \<noteq> {})\<rbrakk> \<Longrightarrow>
Structures_A.obj_refs cap \<inter> Structures_A.obj_refs cap' \<noteq> {} \<or>
cap_irqs cap \<inter> cap_irqs cap' \<noteq> {}"
apply(simp add: is_derived_def)
apply(case_tac cap', simp_all add: cap_master_cap_def split: cap.splits arch_cap.splits)
done
lemma is_derived_overlaps:
"\<lbrakk>cte_wp_at (is_derived (cdt s) slot cap) slot s;
Structures_A.obj_refs cap \<noteq> {} \<or> cap_irqs cap \<noteq> {}\<rbrakk> \<Longrightarrow>
slot \<in> slots_holding_overlapping_caps cap s"
apply(simp add: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
apply(drule cte_wp_at_eqD)
apply(erule exE, rename_tac cap')
apply(rule_tac x=cap' in exI)
apply(blast dest: is_derived_overlaps')
done
lemma is_derived_overlaps2:
"\<lbrakk>cte_wp_at (op = cap') slot s;
is_derived (cdt s) slot cap cap';
Structures_A.obj_refs cap' \<noteq> {} \<or> cap_irqs cap' \<noteq> {}\<rbrakk> \<Longrightarrow>
slot \<in> slots_holding_overlapping_caps cap' s"
apply(simp add: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
apply(blast dest: cte_wp_at_eqD is_derived_overlaps')
done
lemma disj_dup: "A \<and> B \<and> C \<and> C'\<Longrightarrow> A \<and> B \<and> C \<and> A \<and> B \<and> C'"
apply simp
done
lemma cap_insert_silc_inv:
"\<lbrace> silc_inv aag st and (\<lambda>s. cte_wp_at (is_derived (cdt s) slot cap) slot s) and
K (pasObjectAbs aag (fst slot) = pasObjectAbs aag (fst slot') \<and> pasObjectAbs aag (fst slot') \<noteq> SilcLabel) \<rbrace>
cap_insert cap slot slot'
\<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
unfolding cap_insert_def
(* The order here matters. The first two need to be first. *)
apply (wp assert_wp static_imp_conj_wp set_cap_silc_inv hoare_vcg_ex_lift
set_untyped_cap_as_full_slots_holding_overlapping_caps_other[where aag=aag]
get_cap_wp update_cdt_silc_inv | simp | wp_once hoare_drop_imps)+
apply clarsimp
apply (rule disj_dup)
apply(rule conjI)
apply(rule impI)
apply(drule is_derived_overlaps)
apply(erule nonempty_refs)
apply(drule overlapping_slots_have_labelled_overlapping_caps)
apply assumption
apply simp
apply fastforce
apply (rule conjI)
apply(rule impI)
apply(drule cte_wp_at_eqD)
apply(elim conjE exE)
apply(drule (1) cte_wp_at_eqD2)
apply simp
apply(drule_tac cap'=capa in is_derived_overlaps2)
apply assumption
apply(erule nonempty_refs)
apply(drule overlapping_slots_have_labelled_overlapping_caps)
apply assumption
apply simp
apply fastforce
apply (drule silc_inv_all_children)
apply (rule conjI)
apply (fastforce simp: all_children_def simp del: split_paired_All)+
done
lemma cap_move_cte_wp_at_other:
"\<lbrace> cte_wp_at P slot and K (slot \<noteq> dest_slot \<and> slot \<noteq> src_slot) \<rbrace>
cap_move cap src_slot dest_slot
\<lbrace> \<lambda>_. cte_wp_at P slot \<rbrace>"
unfolding cap_move_def
apply (rule hoare_pre)
apply (wp set_cdt_cte_wp_at set_cap_cte_wp_at' dxo_wp_weak static_imp_wp | simp)+
done
lemma cte_wp_at_weak_derived_ReplyCap:
"cte_wp_at (op = (ReplyCap x False)) slot s
\<Longrightarrow> cte_wp_at (weak_derived (ReplyCap x False)) slot s"
apply(erule cte_wp_atE)
apply(rule cte_wp_at_cteI)
apply assumption
apply assumption
apply assumption
apply simp
apply(rule cte_wp_at_tcbI)
apply auto
done
lemma cte_wp_at_eq:
assumes a: "\<And> cap. \<lbrace> cte_wp_at (op = cap) slot \<rbrace> f \<lbrace> \<lambda>_. cte_wp_at (op = cap) slot \<rbrace>"
shows "\<lbrace> cte_wp_at P slot \<rbrace> f \<lbrace> \<lambda>_. cte_wp_at P slot \<rbrace>"
apply(clarsimp simp: valid_def)
apply(drule cte_wp_at_eqD)
apply(elim exE conjE, rename_tac cap)
apply(drule use_valid)
apply(rule a)
apply assumption
apply(simp add: cte_wp_at_def)
done
lemma set_endpoint_silc_inv[wp]:
"\<lbrace> silc_inv aag st \<rbrace>
set_endpoint ptr ep
\<lbrace> \<lambda> _. silc_inv aag st \<rbrace>"
unfolding set_endpoint_def
apply(rule silc_inv_pres)
apply(wp set_object_wp get_object_wp)
apply (simp split: kernel_object.splits)
apply(rule impI | simp)+
apply(fastforce simp: silc_inv_def obj_at_def is_cap_table_def)
apply(wp set_object_wp get_object_wp | simp)+
apply(case_tac "ptr = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(fastforce elim: cte_wp_atE simp: obj_at_def)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
lemma set_notification_silc_inv[wp]:
"\<lbrace> silc_inv aag st \<rbrace>
set_notification ptr ntfn
\<lbrace> \<lambda> _. silc_inv aag st \<rbrace>"
unfolding set_notification_def
apply(rule silc_inv_pres)
apply(wp set_object_wp get_object_wp)
apply (simp split: kernel_object.splits)
apply(rule impI | simp)+
apply(fastforce simp: silc_inv_def obj_at_def is_cap_table_def)
apply(wp set_object_wp get_object_wp | simp)+
apply(case_tac "ptr = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(fastforce elim: cte_wp_atE simp: obj_at_def)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
crunch kheap[wp]: deleted_irq_handler "\<lambda>s. P (kheap s x)"
crunch silc_inv[wp]: deleted_irq_handler "silc_inv aag st"
(wp: silc_inv_triv)
end
lemma (in is_extended') not_cte_wp_at[wp]: "I (\<lambda>s. \<not> cte_wp_at P t s)" by (rule lift_inv,simp)
context begin interpretation Arch . (*FIXME: arch_split*)
lemma set_thread_state_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace>
set_thread_state tptr ts
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding set_thread_state_def
apply(rule silc_inv_pres)
apply(wp set_object_wp|simp split del: if_split)+
apply (simp split: kernel_object.splits)
apply(rule impI | simp)+
apply(fastforce simp: silc_inv_def dest: get_tcb_SomeD simp: obj_at_def is_cap_table_def)
apply(wp set_object_wp | simp)+
apply(case_tac "tptr = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(erule notE)
apply(erule cte_wp_atE)
apply(fastforce simp: obj_at_def)
apply(drule get_tcb_SomeD)
apply(rule cte_wp_at_tcbI)
apply(simp)
apply assumption
apply (fastforce simp: tcb_cap_cases_def split: if_splits)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
lemma set_bound_notification_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace>
set_bound_notification tptr ntfn
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding set_bound_notification_def
apply(rule silc_inv_pres)
apply(wp set_object_wp|simp split del: if_split)+
apply (simp split: kernel_object.splits)
apply(rule impI | simp)+
apply(fastforce simp: silc_inv_def dest: get_tcb_SomeD simp: obj_at_def is_cap_table_def)
apply(wp set_object_wp | simp)+
apply(case_tac "tptr = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(erule notE)
apply(erule cte_wp_atE)
apply(fastforce simp: obj_at_def)
apply(drule get_tcb_SomeD)
apply(rule cte_wp_at_tcbI)
apply(simp)
apply assumption
apply (fastforce simp: tcb_cap_cases_def split: if_splits)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
crunch silc_inv[wp]: fast_finalise, unbind_notification "silc_inv aag st"
(ignore: set_object wp: crunch_wps simp: crunch_simps)
lemma slots_holding_overlapping_caps_lift:
assumes a: "\<And> P Q slot. \<lbrace> \<lambda> s. Q (cte_wp_at P slot s) \<rbrace> f \<lbrace> \<lambda>_ s. Q (cte_wp_at P slot s) \<rbrace>"
shows "\<lbrace> \<lambda> s. P (slots_holding_overlapping_caps cap s) \<rbrace> f \<lbrace> \<lambda>_ s. P (slots_holding_overlapping_caps cap s) \<rbrace>"
apply(clarsimp simp: valid_def)
apply(subgoal_tac "slots_holding_overlapping_caps cap b = slots_holding_overlapping_caps cap s", simp)
apply(clarsimp simp: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
apply(rule Collect_cong)
apply(erule use_valid[OF _ a])
apply(rule refl)
done
crunch cte_wp_at'[wp]: set_original "\<lambda> s. Q (cte_wp_at P slot s)"
lemma slots_holding_overlapping_caps_exst_update[simp]:
"slots_holding_overlapping_caps cap (trans_state f s) =
slots_holding_overlapping_caps cap s"
apply(simp add: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
done
crunch cte_wp_at'[wp]: set_cdt "\<lambda> s. Q (cte_wp_at P slot s)"
lemma slots_holding_overlapping_caps_is_original_cap_update[simp]:
"slots_holding_overlapping_caps cap (s\<lparr>is_original_cap := X\<rparr>) =
slots_holding_overlapping_caps cap s"
apply(simp add: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
done
lemma intra_label_cap_is_original_cap[simp]:
"intra_label_cap aag slot (s\<lparr>is_original_cap := X\<rparr>) = intra_label_cap aag slot s"
apply(simp add: intra_label_cap_def)
done
lemma silc_inv_is_original_cap[simp]:
"silc_inv aag st (s\<lparr>is_original_cap := X\<rparr>) = silc_inv aag st s"
apply(simp add: silc_inv_def silc_dom_equiv_def equiv_for_def)
done
lemma empty_slot_silc_inv:
"\<lbrace>silc_inv aag st and K (pasObjectAbs aag (fst slot) \<noteq> SilcLabel)\<rbrace>
empty_slot slot free_irq
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding empty_slot_def
apply(wp set_cap_silc_inv hoare_vcg_all_lift hoare_vcg_ex_lift
slots_holding_overlapping_caps_lift get_cap_wp
set_cdt_silc_inv dxo_wp_weak
| wpc | simp del: empty_slot_extended.dxo_eq)+
apply(clarsimp simp: cap_points_to_label_def)
apply (drule silc_inv_all_children)
apply (fastforce simp: all_children_def simp del: split_paired_All)
done
lemma cap_delete_one_silc_inv:
"\<lbrace>silc_inv aag st and K (is_subject aag (fst slot)) \<rbrace>
cap_delete_one slot
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding cap_delete_one_def
apply (wp hoare_unless_wp empty_slot_silc_inv get_cap_wp | simp)+
apply (clarsimp simp: silc_inv_def)
done
lemma thread_set_silc_inv:
assumes cap_inv: "\<And>tcb. \<forall>(getF, v) \<in> ran tcb_cap_cases. getF (f tcb) = getF tcb"
shows "\<lbrace>silc_inv aag st\<rbrace> thread_set f t \<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply (rule silc_inv_pres)
apply (subst thread_set_def)
apply (wp set_object_wp)
apply (simp split: kernel_object.splits)
apply (rule impI | simp)+
apply (fastforce simp: silc_inv_def dest: get_tcb_SomeD simp: obj_at_def is_cap_table_def)
apply (rule thread_set_Pmdb)
apply (rule thread_set_cte_wp_at_trivial[OF cap_inv])
done
lemma thread_set_tcb_fault_update_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace>
thread_set (tcb_fault_update blah) t
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
by (rule thread_set_silc_inv; simp add: tcb_cap_cases_def)
lemma reply_cancel_ipc_silc_inv:
"\<lbrace>silc_inv aag st and pas_refined aag and K (is_subject aag t) \<rbrace>
reply_cancel_ipc t
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding reply_cancel_ipc_def including no_pre
apply ((wp cap_delete_one_silc_inv select_wp hoare_vcg_if_lift)+ | simp)+
(* there must be a better way to do this... *)
apply (clarsimp simp: valid_def)
apply (rule conjI)
apply clarsimp
apply(rule conjI)
apply(erule use_valid)
apply wp
apply assumption
apply(subgoal_tac "descendants_of (t, tcb_cnode_index 2) (cdt b) = descendants_of (t, tcb_cnode_index 2) (cdt s)")
apply(drule descendants_of_owned)
apply fastforce
apply simp
apply simp
apply(erule use_valid[OF _ thread_set_Pmdb])
apply(rule refl)
apply(fastforce elim: use_valid[OF _ thread_set_tcb_fault_update_silc_inv])
done
crunch silc_inv[wp]: cancel_signal "silc_inv aag st"
lemma cancel_ipc_silc_inv:
"\<lbrace>silc_inv aag st and pas_refined aag and K (is_subject aag t) \<rbrace>
cancel_ipc t
\<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
unfolding cancel_ipc_def
apply(wp get_endpoint_wp reply_cancel_ipc_silc_inv get_thread_state_inv hoare_vcg_all_lift
| wpc
| simp(no_asm) add: blocked_cancel_ipc_def get_ep_queue_def
get_blocking_object_def
| wp_once hoare_drop_imps)+
apply auto
done
lemma cancel_ipc_indirect_silc_inv:
"\<lbrace>silc_inv aag st and st_tcb_at receive_blocked t \<rbrace>
cancel_ipc t
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding cancel_ipc_def
apply (rule hoare_seq_ext[OF _ gts_sp])
apply (rule hoare_name_pre_state)
apply (clarsimp simp: st_tcb_def2 receive_blocked_def)
apply (simp add: blocked_cancel_ipc_def split: thread_state.splits)
apply (wp)
apply simp
done
lemma intra_label_cap_machine_state[simp]:
"intra_label_cap aag slot (s\<lparr>machine_state := X\<rparr>) = intra_label_cap aag slot s"
apply(simp add: intra_label_cap_def)
done
lemma slots_holding_overlapping_caps_machine_state[simp]:
"slots_holding_overlapping_caps cap (s\<lparr>machine_state := X\<rparr>) = slots_holding_overlapping_caps cap s"
apply(simp add: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
done
lemma silc_inv_machine_state[simp]:
"silc_inv aag st (s\<lparr>machine_state := X\<rparr>) = silc_inv aag st s"
apply(simp add: silc_inv_def silc_dom_equiv_def equiv_for_def)
done
lemma intra_label_cap_arch_state[simp]:
"intra_label_cap aag slot (s\<lparr>arch_state := X\<rparr>) = intra_label_cap aag slot s"
apply(simp add: intra_label_cap_def)
done
lemma slots_holding_overlapping_caps_arch_state[simp]:
"slots_holding_overlapping_caps cap (s\<lparr>arch_state := X\<rparr>) = slots_holding_overlapping_caps cap s"
apply(simp add: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
done
lemma silc_inv_arch_state[simp]:
"silc_inv aag st (s\<lparr>arch_state := X\<rparr>) = silc_inv aag st s"
apply(simp add: silc_inv_def silc_dom_equiv_def equiv_for_def)
done
lemma set_pt_silc_inv[wp]:
"\<lbrace> silc_inv aag st \<rbrace>
set_pt ptr pt
\<lbrace> \<lambda> _. silc_inv aag st \<rbrace>"
unfolding set_pt_def
apply(rule silc_inv_pres)
apply(wp set_object_wp get_object_wp)
apply (simp split: kernel_object.splits)
apply(rule impI | simp)+
apply(fastforce simp: silc_inv_def obj_at_def is_cap_table_def)
apply(wp set_object_wp get_object_wp | simp)+
apply(case_tac "ptr = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(fastforce elim: cte_wp_atE simp: obj_at_def)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
lemma set_pd_silc_inv[wp]:
"\<lbrace> silc_inv aag st \<rbrace>
set_pd ptr pt
\<lbrace> \<lambda> _. silc_inv aag st \<rbrace>"
unfolding set_pd_def
apply(rule silc_inv_pres)
apply(wp set_object_wp get_object_wp)
apply (simp split: kernel_object.splits)
apply(rule impI | simp)+
apply(fastforce simp: silc_inv_def obj_at_def is_cap_table_def)
apply(wp set_object_wp get_object_wp | simp)+
apply(case_tac "ptr = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(fastforce elim: cte_wp_atE simp: obj_at_def)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
lemma set_asid_pool_silc_inv[wp]:
"\<lbrace> silc_inv aag st \<rbrace>
set_asid_pool ptr pt
\<lbrace> \<lambda> _. silc_inv aag st \<rbrace>"
unfolding set_asid_pool_def
apply(rule silc_inv_pres)
apply(wp set_object_wp get_object_wp)
apply (simp split: kernel_object.splits)
apply(rule impI | simp)+
apply(fastforce simp: silc_inv_def obj_at_def is_cap_table_def)
apply(wp set_object_wp get_object_wp | simp)+
apply(case_tac "ptr = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(fastforce elim: cte_wp_atE simp: obj_at_def)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
crunch silc_inv[wp]: arch_finalise_cap,prepare_thread_delete "silc_inv aag st"
(wp: crunch_wps modify_wp simp: crunch_simps ignore: set_object)
lemma finalise_cap_silc_inv:
"\<lbrace> silc_inv aag st and pas_refined aag and K (pas_cap_cur_auth aag cap)\<rbrace> finalise_cap cap final \<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(case_tac cap)
apply(wp cancel_ipc_silc_inv | simp split del: if_split add: suspend_def| clarsimp)+
apply(clarsimp simp: aag_cap_auth_Thread)
apply(wp | simp split del: if_split | clarsimp split del: if_split)+
apply(rule hoare_pre)
apply (wp cap_delete_one_silc_inv | simp add: deleting_irq_handler_def)+
apply (fastforce simp: aag_cap_auth_def cap_links_irq_def elim: aag_Control_into_owns_irq)
apply(wp | simp split del: if_split)+
done
lemma validE_validE_R':
"\<lbrace> P \<rbrace> f \<lbrace> Q \<rbrace>,\<lbrace> R \<rbrace> \<Longrightarrow> \<lbrace> P \<rbrace> f \<lbrace> Q \<rbrace>,-"
apply(rule validE_validE_R)
apply(erule hoare_post_impErr)
by auto
lemma finalise_cap_ret_subset_cap_irqs:
"\<lbrace>\<lambda> s. (cap_irqs cap) = X\<rbrace> finalise_cap cap blah \<lbrace>\<lambda>rv s. (cap_irqs (fst rv)) \<subseteq> X\<rbrace>"
apply(case_tac cap)
apply(wp | simp add: o_def split del: if_split)+
apply(simp split: if_split)
apply(wp | simp add: o_def | safe)+
apply(simp add: arch_finalise_cap_def)
apply(rule hoare_pre)
apply(wpc | wp | simp)+
done
lemma finalise_cap_ret_subset_obj_refs:
"\<lbrace>\<lambda> s. (Structures_A.obj_refs cap) = X\<rbrace> finalise_cap cap blah \<lbrace>\<lambda>rv s. (Structures_A.obj_refs (fst rv)) \<subseteq> X\<rbrace>"
apply(case_tac cap)
apply(wp | simp add: o_def split del: if_split)+
apply(simp split: if_split)
apply(wp | simp add: o_def | safe)+
apply(simp add: arch_finalise_cap_def)
apply(rule hoare_pre)
apply(wpc | wp | simp)+
done
lemma finalise_cap_ret_intra_label_cap:
"\<lbrace>\<lambda> s. cap_points_to_label aag cap l\<rbrace> finalise_cap cap blah \<lbrace>\<lambda>rv s. cap_points_to_label aag (fst rv) l\<rbrace>"
apply(clarsimp simp: cap_points_to_label_def valid_def)
apply(rule conjI)
apply(erule ball_subset)
apply(drule use_valid[OF _ finalise_cap_ret_subset_obj_refs])
apply(rule refl)
apply simp
apply(erule ball_subset)
apply(drule use_valid[OF _ finalise_cap_ret_subset_cap_irqs])
apply(rule refl)
by simp
lemma silc_inv_preserves_silc_dom_caps:
"\<lbrakk>silc_inv aag st s; silc_inv aag st s';
pasObjectAbs aag (fst lslot) = SilcLabel;
lslot \<in> FinalCaps.slots_holding_overlapping_caps cap s\<rbrakk> \<Longrightarrow>
lslot \<in> FinalCaps.slots_holding_overlapping_caps cap s'"
apply(clarsimp simp: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
apply(rule_tac x=cap' in exI)
apply simp
apply(subst (asm) cte_wp_at_pspace'[where s'=s'])
apply(fastforce simp: silc_inv_def silc_dom_equiv_def equiv_for_def)
apply assumption
done
lemma finalise_cap_ret_is_silc:
"\<lbrace>silc_inv aag st and cte_wp_at (op = cap) slot and
pas_refined aag and K (pas_cap_cur_auth aag cap)\<rbrace>
finalise_cap cap blah
\<lbrace>\<lambda>rvb s. (\<not> cap_points_to_label aag (fst rvb) (pasObjectAbs aag (fst slot)) \<longrightarrow>
(\<exists> lslot. lslot
\<in> FinalCaps.slots_holding_overlapping_caps (fst rvb) s \<and>
pasObjectAbs aag (fst lslot) = SilcLabel))\<rbrace>"
apply(clarsimp simp: valid_def)
apply(rename_tac a b s')
apply(cut_tac aag1=aag and r="(a,b)" and l1="pasObjectAbs aag (fst slot)" in hoare_contrapositive[OF finalise_cap_ret_intra_label_cap])
apply simp
apply assumption
apply(frule use_valid[OF _ finalise_cap_silc_inv[where aag=aag and st=st]])
apply simp
apply(frule_tac s=s in silc_invD)
apply assumption
apply(fastforce simp: intra_label_cap_def)
apply(simp, elim exE conjE)
apply(rename_tac la lb)
apply(rule_tac x=la in exI, simp)
apply(rule_tac x=lb in exI)
apply(drule_tac lslot="(la,lb)" in silc_inv_preserves_silc_dom_caps, simp+)
apply(drule nonempty_refs)+
apply(erule disjE[where P="Structures_A.obj_refs cap \<noteq> {}"])
apply(subgoal_tac "cap_irqs cap = {} \<and> cap_irqs a = {}")
apply(clarsimp simp: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
apply(rename_tac cap'a)
apply(rule_tac x=cap'a in exI)
apply simp
apply(subgoal_tac "\<exists> x. Structures_A.obj_refs cap = {x} \<and> Structures_A.obj_refs a = {x}")
apply blast
apply(erule nonemptyE)
apply(rename_tac x)
apply(rule_tac x=x in exI)
apply(subgoal_tac "Structures_A.obj_refs a \<subseteq> Structures_A.obj_refs cap")
apply(drule (1) subsetD)
apply(blast dest: caps_ref_single_objects)
apply(fastforce dest: use_valid[OF _ finalise_cap_ret_subset_obj_refs])
apply(fastforce dest: caps_ref_either_an_object_or_irq use_valid[OF _ finalise_cap_ret_subset_cap_irqs])
apply(subgoal_tac "Structures_A.obj_refs cap = {} \<and> Structures_A.obj_refs a = {}")
apply(clarsimp simp: slots_holding_overlapping_caps_def get_cap_cte_wp_at')
apply(rename_tac cap'a)
apply(rule_tac x=cap'a in exI)
apply simp
apply(subgoal_tac "\<exists> x. cap_irqs cap = {x} \<and> cap_irqs a = {x}")
apply blast
apply(erule nonemptyE)
apply(rename_tac x)
apply(rule_tac x=x in exI)
apply(subgoal_tac "cap_irqs a \<subseteq> cap_irqs cap")
apply(drule (1) subsetD)
apply(blast dest: caps_ref_single_irqs)
apply(fastforce dest: use_valid[OF _ finalise_cap_ret_subset_cap_irqs])
apply(fastforce dest: caps_ref_either_an_object_or_irq' use_valid[OF _ finalise_cap_ret_subset_obj_refs])
done
lemma arch_finalise_cap_ret:
"(rv, s') \<in> fst (arch_finalise_cap arch_cap final s) \<Longrightarrow> rv = NullCap"
apply(erule use_valid)
unfolding arch_finalise_cap_def
apply(wp | wpc | simp)+
done
lemma finalise_cap_ret:
"(rv, s') \<in> fst (finalise_cap cap final s) \<Longrightarrow> case (fst rv) of NullCap \<Rightarrow> True | Zombie ptr bits n \<Rightarrow> True | _ \<Rightarrow> False"
apply(case_tac cap, simp_all add: return_def)
apply(fastforce simp: liftM_def when_def bind_def return_def split: if_split_asm)+
apply(clarsimp simp: bind_def liftM_def return_def)
apply(drule arch_finalise_cap_ret)
apply(simp)
done
lemma finalise_cap_ret_is_subject:
"\<lbrace>K ((is_cnode_cap cap \<or> is_thread_cap cap \<or> is_zombie cap) \<longrightarrow> is_subject aag (obj_ref_of cap))\<rbrace> finalise_cap cap is_final \<lbrace>\<lambda>rv _. case (fst rv) of Zombie ptr bits n \<Rightarrow> is_subject aag (obj_ref_of (fst rv)) | _ \<Rightarrow> True\<rbrace>"
including no_pre
apply(case_tac cap, simp_all add: is_zombie_def)
apply(wp | simp add: comp_def | rule impI | rule conjI)+
apply(fastforce simp: valid_def dest: arch_finalise_cap_ret)
done
lemma finalise_cap_ret_is_subject':
"\<lbrace> K (is_cnode_cap rv \<or> is_thread_cap rv \<or> is_zombie rv \<longrightarrow>
is_subject aag (obj_ref_of rv)) \<rbrace>
finalise_cap rv rva
\<lbrace>\<lambda>rv s. (is_zombie (fst rv) \<longrightarrow> is_subject aag (obj_ref_of (fst rv)))\<rbrace>"
apply(clarsimp simp: valid_def)
apply(drule use_valid[OF _ finalise_cap_ret_is_subject[where aag=aag]])
apply simp
apply(case_tac a, simp_all add: is_zombie_def)
done
lemma get_cap_weak_derived[wp]:
"\<lbrace> \<top> \<rbrace> get_cap slot
\<lbrace>\<lambda>rv s. cte_wp_at (weak_derived rv) slot s\<rbrace>"
unfolding get_cap_def
apply(wp get_object_wp | simp add: split_def | wpc)+
apply safe
apply(rule cte_wp_at_cteI)
apply(fastforce simp: obj_at_def)
apply assumption
apply assumption
apply simp
apply(clarsimp simp: tcb_cnode_map_tcb_cap_cases)
apply(rule cte_wp_at_tcbI)
apply(fastforce simp: obj_at_def)
apply assumption
apply simp
done
crunch silc_inv: cap_swap_for_delete "silc_inv aag st"
(simp: crunch_simps)
lemma get_thread_cap_ret_is_subject:
"\<lbrace>(pas_refined aag) and K (is_subject aag (fst slot))\<rbrace>
get_cap slot
\<lbrace>\<lambda>rv s. is_thread_cap rv \<longrightarrow> (is_subject aag (obj_ref_of rv))\<rbrace>"
apply(clarsimp simp: valid_def)
apply(frule get_cap_det)
apply(drule_tac f=fst in arg_cong)
apply(subst (asm) fst_conv)
apply(drule in_get_cap_cte_wp_at[THEN iffD1])
apply(clarsimp simp: cte_wp_at_caps_of_state)
apply(rule caps_of_state_pasObjectAbs_eq)
apply(blast intro: sym)
apply(fastforce simp: cap_auth_conferred_def split: cap.split)
apply assumption+
apply(case_tac a, simp_all)
done
lemma get_zombie_ret_is_subject:
"\<lbrace>(pas_refined aag) and K (is_subject aag (fst slot))\<rbrace>
get_cap slot
\<lbrace>\<lambda>rv s. is_zombie rv \<longrightarrow> (is_subject aag (obj_ref_of rv))\<rbrace>"
apply(clarsimp simp: valid_def is_zombie_def)
apply(frule get_cap_det)
apply(drule_tac f=fst in arg_cong)
apply(subst (asm) fst_conv)
apply(drule in_get_cap_cte_wp_at[THEN iffD1])
apply(clarsimp simp: cte_wp_at_caps_of_state)
apply(rule caps_of_state_pasObjectAbs_eq)
apply(blast intro: sym)
apply(fastforce simp: cap_auth_conferred_def split: cap.split)
apply assumption+
apply(case_tac a, simp_all)
done
lemma ran_caps_of_state_cte_wp_at:
"(\<forall>cap\<in>ran (caps_of_state s). P cap) \<Longrightarrow>
(\<forall>cap. cte_wp_at (op = cap) slot s \<longrightarrow> P cap)"
apply(simp add: cte_wp_at_caps_of_state)
apply(fastforce)
done
declare if_weak_cong[cong]
lemma pas_refined_wuc_upd[simp]:
"pas_refined aag (work_units_completed_update f s) = pas_refined aag s"
by (simp add: pas_refined_def)
lemma rec_del_pas_refined:
notes drop_spec_valid[wp_split del] drop_spec_validE[wp_split del]
drop_spec_ev[wp_split del] rec_del.simps[simp del]
shows
"s \<turnstile> \<lbrace>pas_refined aag and K (case call of
CTEDeleteCall slot exposed \<Rightarrow> is_subject aag (fst slot) |
FinaliseSlotCall slot exposed \<Rightarrow> is_subject aag (fst slot) |
ReduceZombieCall cap slot exposed \<Rightarrow> is_subject aag (fst slot) \<and>
is_subject aag (obj_ref_of cap))\<rbrace>
rec_del call \<lbrace>K (pas_refined aag)\<rbrace>, \<lbrace>K (pas_refined aag)\<rbrace>"
proof (induct rule: rec_del.induct, simp_all only: rec_del_fails hoare_fail_any)
case (1 slot exposed s) show ?case
apply(simp add: split_def rec_del.simps)
apply(rule hoare_pre_spec_validE)
apply(wp)
apply(rule drop_spec_validE, wp)
apply(rule drop_spec_validE, wp)
apply(simp)
apply(rule_tac Q'="\<lambda>_ s. pas_refined aag s \<and> is_subject aag (fst slot)" and E="\<lambda>_. pas_refined aag" in spec_strengthen_postE)
apply(rule spec_valid_conj_liftE2)
apply(wp)
apply(rule "1.hyps"[simplified])
apply(simp)+
done
next
case (2 slot exposed s) show ?case
apply(simp add: rec_del.simps)
apply(rule hoare_pre_spec_validE)
apply(wp)
apply(rule drop_spec_validE, wp+)
apply(simp add: split_def)
apply(rule conjI | rule impI)+
apply(rule_tac P="pas_refined aag and K (is_subject aag (fst slot) \<and> (is_zombie (fst rvb) \<longrightarrow> is_subject aag (obj_ref_of (fst rvb)) \<and> aag_cap_auth aag (pasObjectAbs aag (fst slot)) (fst rvb)))" in hoare_pre_spec_validE)
apply(rule drop_spec_validE, wp)
apply(simp)
apply(wp | simp | rule impI | rule conjI)+
apply(rule drop_spec_validE, wp)
apply(rule drop_spec_validE, wp)
apply(clarsimp simp: is_zombie_def)
apply(simp)
apply(wp | simp | rule impI | rule conjI)+
apply(rule drop_spec_validE, wp)
apply(simp)
apply(rule impI, wp)
apply(rule "2.hyps"[simplified])
apply(simp)+
apply(rule drop_spec_validE, (wp preemption_point_inv'|simp)+)
apply(rule spec_valid_conj_liftE2)
apply(wp)
apply(rule "2.hyps"[simplified])
apply(simp)+
apply(wp drop_spec_validE | simp | clarsimp)+
apply(drule finalise_cap_ret)
apply(case_tac "fst (a,b)")
apply(simp add: is_zombie_def)+
apply(clarsimp)
apply(drule finalise_cap_ret)
apply(case_tac "fst (a,b)")
apply(simp add: is_zombie_def)+
apply(wp drop_spec_validE)
apply (rule_tac Q="\<lambda>rv s. pas_refined aag s \<and> is_subject aag (fst slot) \<and> (case (fst rv) of Zombie ptr bits n \<Rightarrow> is_subject aag (obj_ref_of (fst rv)) | _ \<Rightarrow> True) \<and> pas_cap_cur_auth aag (fst rv) \<and> (is_zombie (fst rv) \<or> fst rv = NullCap)" in hoare_strengthen_post)
apply(wp finalise_cap_ret_is_subject)
apply(wp finalise_cap_auth')
apply(simp add: valid_def)
apply(clarsimp)
apply(drule_tac rv="(a,b)" in finalise_cap_ret)
apply(clarsimp simp: is_zombie_def)
apply(case_tac a)
apply(clarsimp)+
apply(simp split: cap.splits)
apply(wp drop_spec_validE)
apply(simp)
apply(wp)
apply(simp)
apply(rule_tac Q'="\<lambda>rva s. pas_refined aag s \<and> pas_cap_cur_auth aag rv \<and> is_subject aag (fst slot) \<and> (is_cnode_cap rv \<longrightarrow> is_subject aag (obj_ref_of rv)) \<and>
(is_thread_cap rv \<longrightarrow> is_subject aag (obj_ref_of rv)) \<and>
(is_zombie rv \<longrightarrow> is_subject aag (obj_ref_of rv))" in hoare_post_imp_R)
apply(wp)
apply(simp)
apply(simp)
apply(wp drop_spec_validE hoare_drop_imps)
apply(rule_tac Q="\<lambda>s. pas_refined aag s \<and> is_subject aag (fst slot) \<and>
(\<forall>cap. cte_wp_at (op = cap) slot s \<longrightarrow> pas_cap_cur_auth aag cap)"
in hoare_weaken_pre)
apply(rule hoare_conjI)
apply(rule hoare_weaken_pre, rule get_cap_wp, simp)
apply(wp get_cap_ret_is_subject get_thread_cap_ret_is_subject get_zombie_ret_is_subject)
apply(simp | clarsimp)+
apply(simp add: cte_wp_at_caps_of_state)
apply(frule cap_cur_auth_caps_of_state)
apply(simp)+
done
next
case (3 ptr bits n slot s) show ?case
apply(simp add: rec_del.simps)
apply(wp drop_spec_validE)
apply(clarsimp)
done
next
case (4 ptr bits n slot s) show ?case
apply(simp add: rec_del.simps)
apply(wp)
apply(wp drop_spec_validE | simp)+
apply(rule_tac Q="\<lambda>rv s. pas_refined aag s \<and> is_subject aag (fst slot) \<and> (ptr = obj_ref_of rv \<longrightarrow> is_zombie rv \<longrightarrow> is_subject aag (obj_ref_of rv)) \<and> (rv = Zombie ptr bits (Suc n) \<longrightarrow> pas_cap_cur_auth aag rv)" in hoare_strengthen_post)
apply(rule_tac Q="\<lambda>s. pas_refined aag s \<and> is_subject aag (fst slot)" in hoare_weaken_pre)
apply(rule hoare_conjI, wp, simp)
apply(rule hoare_conjI, wp, simp)
apply(rule hoare_conjI)
apply(rule hoare_drop_imps)
apply(wp get_zombie_ret_is_subject)
apply(simp)
apply(rule hoare_weaken_pre)
apply(rule get_cap_wp)
apply(clarsimp)
apply(simp add: cte_wp_at_caps_of_state)
apply(frule cap_cur_auth_caps_of_state)
apply(simp)+
apply(clarsimp)
apply(simp add: aag_cap_auth_def)
apply(simp add: cap_auth_conferred_def)
apply(simp add: cap_links_asid_slot_def cap_links_irq_def)
apply(simp)
apply(rule_tac P'="\<lambda>s. (pas_refined aag s \<and> is_subject aag (fst slot) \<and> is_subject aag ptr) \<and> pas_refined aag s \<and> is_subject aag (fst slot) \<and> is_subject aag ptr" in hoare_pre_spec_validE)
apply(rule spec_valid_conj_liftE2)
apply(wp, simp)
apply(rule hoare_pre_spec_validE)
apply(rule "4.hyps"[simplified])
apply(simp add: returnOk_def return_def)+
done
qed
lemma rec_del_pas_refined':
"\<lbrace>pas_refined aag and K (case call of
CTEDeleteCall slot exposed \<Rightarrow> is_subject aag (fst slot) |
FinaliseSlotCall slot exposed \<Rightarrow> is_subject aag (fst slot) |
ReduceZombieCall cap slot exposed \<Rightarrow> is_subject aag (fst slot) \<and>
is_subject aag (obj_ref_of cap))\<rbrace>
rec_del call \<lbrace>K (pas_refined aag)\<rbrace>, \<lbrace>K (pas_refined aag)\<rbrace>"
apply(rule use_spec)
apply(rule rec_del_pas_refined)
done
lemma finalise_cap_ret':
"\<lbrace>\<top>\<rbrace> finalise_cap cap final
\<lbrace>\<lambda>rv s. (is_zombie (fst rv) \<or> fst rv = NullCap)\<rbrace>"
apply(auto simp: valid_def dest!: finalise_cap_ret split: cap.splits simp: is_zombie_def)
done
lemma silc_inv_irq_state_independent_A[simp, intro!]:
"irq_state_independent_A (silc_inv aag st)"
apply(simp add: silc_inv_def irq_state_independent_A_def silc_dom_equiv_def equiv_for_def)
done
lemma rec_del_silc_inv':
notes drop_spec_valid[wp_split del] drop_spec_validE[wp_split del]
drop_spec_ev[wp_split del] rec_del.simps[simp del]
shows
"s \<turnstile> \<lbrace> silc_inv aag st and pas_refined aag and K (case call of
CTEDeleteCall slot exposed \<Rightarrow> is_subject aag (fst slot) |
FinaliseSlotCall slot exposed \<Rightarrow> is_subject aag (fst slot) |
ReduceZombieCall cap slot exposed \<Rightarrow> is_subject aag (fst slot) \<and>
is_subject aag (obj_ref_of cap))\<rbrace>
(rec_del call)
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>,\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
proof (induct s arbitrary: rule: rec_del.induct, simp_all only: rec_del_fails hoare_fail_any)
case (1 slot exposed s) show ?case
apply(simp add: split_def rec_del.simps)
apply(rule hoare_pre_spec_validE)
apply(wp empty_slot_silc_inv drop_spec_validE[OF returnOk_wp] drop_spec_validE[OF liftE_wp] | simp)+
apply(rule_tac Q'="\<lambda>_ s. silc_inv aag st s \<and> is_subject aag (fst slot)" and E="\<lambda>_. silc_inv aag st" in spec_strengthen_postE)
apply(rule spec_valid_conj_liftE2)
apply(wp)
apply(rule "1.hyps"[simplified])
apply(simp | fastforce simp: silc_inv_def)+
done
next
case (2 slot exposed s) show ?case
apply(simp add: rec_del.simps split del: if_split)
apply(rule hoare_pre_spec_validE)
apply(wp drop_spec_validE[OF returnOk_wp] drop_spec_validE[OF liftE_wp] set_cap_silc_inv
"2.hyps"
|simp add: split_def split del: if_split)+
apply(rule drop_spec_validE, (wp preemption_point_inv'| simp)+)[1]
apply simp
apply(rule spec_valid_conj_liftE2)
apply(wp validE_validE_R'[OF rec_del_pas_refined'[simplified]] "2.hyps"
drop_spec_validE[OF liftE_wp] set_cap_silc_inv
|simp add: without_preemption_def split del: if_split)+
(* where the action is *)
apply(simp cong: conj_cong add: conj_comms)
apply(rule_tac Q="\<lambda> rvb s. pas_refined aag s \<and>
silc_inv aag st s \<and>
pasSubject aag \<noteq> SilcLabel \<and>
pas_cap_cur_auth aag (fst rvb) \<and>
is_subject aag (fst slot) \<and>
(is_zombie (fst rvb) \<or> fst rvb = NullCap) \<and>
(is_zombie (fst rvb) \<longrightarrow> is_subject aag (obj_ref_of (fst rvb))) \<and>
(\<not> cap_points_to_label aag (fst rvb) (pasObjectAbs aag (fst slot)) \<longrightarrow>
(\<exists>slot. slot \<in> FinalCaps.slots_holding_overlapping_caps (fst rvb) s
\<and> pasObjectAbs aag (fst slot) = SilcLabel))" in hoare_strengthen_post)
prefer 2
apply (fastforce)
apply(wp finalise_cap_pas_refined finalise_cap_silc_inv finalise_cap_auth' finalise_cap_ret' finalise_cap_ret_is_subject' finalise_cap_ret_is_silc[where st=st])[1]
apply(wp drop_spec_validE[OF liftE_wp] get_cap_auth_wp[where aag=aag] | simp add: without_preemption_def)+
apply (clarsimp simp: conj_comms cong: conj_cong simp: caps_of_state_cteD)
apply (rule conjI, clarsimp simp: silc_inv_def)
apply(case_tac cap, simp_all add: is_zombie_def add: aag_cap_auth_CNode aag_cap_auth_Thread aag_cap_auth_Zombie)
done
next
case (3 ptr bits n slot s) show ?case
apply(simp add: rec_del.simps)
apply (wp drop_spec_validE[OF returnOk_wp] drop_spec_validE[OF liftE_wp] cap_swap_for_delete_silc_inv)
apply(simp add: pred_conj_def)
apply(rule hoare_pre_spec_validE)
apply(rule spec_valid_conj_liftE2)
apply (wp | simp)+
apply (wp drop_spec_validE[OF assertE_wp])
apply(fastforce simp: silc_inv_def)
done
next
case (4 ptr bits n slot s) show ?case
apply(simp add: rec_del.simps)
apply (wp drop_spec_validE[OF returnOk_wp] drop_spec_validE[OF liftE_wp] set_cap_silc_inv
drop_spec_validE[OF assertE_wp] get_cap_wp | simp add: without_preemption_def)+
apply (rule_tac Q'="\<lambda> _. silc_inv aag st and
K (pasObjectAbs aag (fst slot) \<noteq> SilcLabel)" in spec_strengthen_postE)
prefer 2
apply (clarsimp)
apply (drule silc_invD)
apply assumption
apply(simp add: intra_label_cap_def)
apply(rule exI)
apply(rule conjI)
apply assumption
apply(fastforce simp: cap_points_to_label_def)
apply(clarsimp simp: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
apply (simp add: pred_conj_def)
apply (rule hoare_pre_spec_validE)
apply(wp spec_valid_conj_liftE2 "4.hyps")
apply(simp add: in_monad)
apply(fastforce simp: silc_inv_def)
done
qed
lemma rec_del_silc_inv:
"\<lbrace> silc_inv aag st and pas_refined aag and K (case call of
CTEDeleteCall slot exposed \<Rightarrow> is_subject aag (fst slot) |
FinaliseSlotCall slot exposed \<Rightarrow> is_subject aag (fst slot) |
ReduceZombieCall cap slot exposed \<Rightarrow> is_subject aag (fst slot) \<and>
is_subject aag (obj_ref_of cap))\<rbrace>
(rec_del call)
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>, \<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(rule use_spec)
apply(rule rec_del_silc_inv')
done
lemma cap_delete_silc_inv:
"\<lbrace> silc_inv aag st and pas_refined aag and K (is_subject aag (fst slot)) \<rbrace>
cap_delete slot
\<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
unfolding cap_delete_def
apply(wp rec_del_silc_inv | simp)+
done
crunch_ignore (valid) (add: getActiveIRQ)
crunch silc_inv[wp]: preemption_point "silc_inv aag st"
(ignore: wrap_ext_bool OR_choiceE simp: OR_choiceE_def crunch_simps wp: crunch_wps)
crunch pas_refined[wp]: preemption_point "pas_refined aag"
(ignore: wrap_ext_bool OR_choiceE simp: OR_choiceE_def crunch_simps wp: crunch_wps)
lemma cap_revoke_silc_inv':
notes drop_spec_valid[wp_split del] drop_spec_validE[wp_split del]
drop_spec_ev[wp_split del] rec_del.simps[simp del]
shows
"s \<turnstile> \<lbrace> silc_inv aag st and pas_refined aag and einvs and simple_sched_action and K (is_subject aag (fst slot)) \<rbrace>
cap_revoke slot
\<lbrace> \<lambda>_. silc_inv aag st \<rbrace>, \<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
proof(induct rule: cap_revoke.induct[where ?a1.0=s])
case (1 slot s)
show ?case
apply(subst cap_revoke.simps)
apply(rule hoare_pre_spec_validE)
apply (wp "1.hyps")
apply(wp spec_valid_conj_liftE2 | simp)+
apply(wp drop_spec_validE[OF valid_validE[OF preemption_point_silc_inv]] cap_delete_silc_inv preemption_point_inv' | simp)+
apply(rule spec_valid_conj_liftE1)
apply(rule validE_validE_R'[OF valid_validE[OF cap_delete_pas_refined]])
apply(rule spec_valid_conj_liftE1, (wp | simp)+)
apply(rule spec_valid_conj_liftE1, (wp | simp)+)
apply(rule spec_valid_conj_liftE1, (wp | simp)+)
apply(rule spec_valid_conj_liftE1, (wp | simp)+)
apply(rule spec_valid_conj_liftE1, (wp | simp)+)
apply(rule drop_spec_validE[OF valid_validE[OF cap_delete_silc_inv]])
apply (wp drop_spec_validE[OF assertE_wp] drop_spec_validE[OF without_preemption_wp] get_cap_wp select_wp drop_spec_validE[OF returnOk_wp])+
apply clarsimp
apply (clarsimp cong: conj_cong simp: conj_comms)
apply (subst conj_commute)
apply (rule conjI)
apply(fastforce dest: descendants_of_owned split: if_splits)
apply (case_tac "next_revoke_cap slot s")
apply (auto simp: emptyable_def dest!: reply_slot_not_descendant split: if_splits)
done
qed
lemma cap_revoke_silc_inv:
"\<lbrace> silc_inv aag st and pas_refined aag and einvs and simple_sched_action and K (is_subject aag (fst slot)) \<rbrace>
cap_revoke slot
\<lbrace> \<lambda>_. silc_inv aag st \<rbrace>, \<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
apply(rule use_spec)
apply(rule cap_revoke_silc_inv')
done
lemma thread_set_tcb_registers_caps_merge_default_tcb_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace>
thread_set (tcb_registers_caps_merge default_tcb) word
\<lbrace>\<lambda>xa. silc_inv aag st\<rbrace>"
by (rule thread_set_silc_inv; simp add: tcb_cap_cases_def tcb_registers_caps_merge_def)
crunch silc_inv[wp]: cancel_badged_sends "silc_inv aag st"
(wp: crunch_wps hoare_unless_wp simp: crunch_simps ignore: filterM set_object thread_set simp: filterM_mapM)
lemma finalise_slot_silc_inv:
"\<lbrace> silc_inv aag st and pas_refined aag and K (is_subject aag (fst slot))\<rbrace>
finalise_slot slot blah
\<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
unfolding finalise_slot_def
apply(rule validE_valid)
apply(rule hoare_pre)
apply(rule rec_del_silc_inv)
apply simp
done
lemma invoke_cnode_silc_inv:
"\<lbrace> silc_inv aag st and einvs and simple_sched_action and pas_refined aag and valid_cnode_inv i and authorised_cnode_inv aag i and is_subject aag \<circ> cur_thread \<rbrace>
invoke_cnode i
\<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
unfolding invoke_cnode_def
apply(case_tac i)
apply(wp cap_insert_silc_inv | simp)+
apply(fastforce simp: silc_inv_def authorised_cnode_inv_def)
apply(wp cap_move_silc_inv | simp)+
apply(fastforce simp: silc_inv_def authorised_cnode_inv_def)
apply(wp cap_revoke_silc_inv | simp)+
apply(fastforce simp: authorised_cnode_inv_def)
apply(wp cap_delete_silc_inv | simp)+
apply(fastforce simp: authorised_cnode_inv_def)
apply(rule hoare_pre)
apply(wp cap_move_silc_inv cap_swap_silc_inv cap_move_cte_wp_at_other | simp split del: if_split)+
apply(fastforce simp: silc_inv_def authorised_cnode_inv_def)
apply(wp cap_move_silc_inv get_cap_wp | wpc | simp)+
apply(clarsimp simp: silc_inv_def authorised_cnode_inv_def)
apply(erule cte_wp_at_weak_derived_ReplyCap)
apply(wp cancel_badged_sends_silc_inv | simp | wpc | rule hoare_pre)+
done
lemma set_cap_default_cap_silc_inv:
"\<lbrace>silc_inv aag st and K (is_subject aag (fst slot) \<and> is_subject aag oref)\<rbrace>
set_cap (default_cap a oref b dev) slot
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(rule hoare_pre)
apply(rule set_cap_silc_inv)
apply (auto simp: cap_points_to_label_def
dest: subsetD[OF obj_refs_default_cap] simp: default_cap_irqs silc_inv_def)
done
lemma create_cap_silc_inv:
"\<lbrace> silc_inv aag st and K (is_subject aag (fst (fst ref)) \<and> is_subject aag (snd ref) \<and> is_subject aag (fst c))\<rbrace>
create_cap a b c dev ref
\<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
unfolding create_cap_def
apply(rule hoare_gen_asm)
apply(wp set_cap_default_cap_silc_inv set_cdt_silc_inv | simp add: split_def)+
apply (subgoal_tac "pasObjectAbs aag (fst c) \<noteq> SilcLabel")
apply (drule silc_inv_all_children)
apply (simp add: all_children_def del: split_paired_All)
apply (clarsimp simp: silc_inv_def)
done
crunch silc_inv[wp]: init_arch_objects "silc_inv aag st"
(wp: crunch_wps hoare_unless_wp simp: crunch_simps)
lemma retype_region_silc_inv:
"\<lbrace>silc_inv aag st and K (range_cover ptr sz (obj_bits_api type o_bits) num_objects \<and>
(\<forall>x\<in>{ptr..(ptr && ~~ mask sz) + (2 ^ sz - 1)}. is_subject aag x)) \<rbrace>
retype_region ptr num_objects o_bits type dev
\<lbrace>\<lambda>_. silc_inv aag st \<rbrace>"
apply(rule hoare_gen_asm)+
apply(simp only: retype_region_def retype_addrs_def
foldr_upd_app_if fun_app_def K_bind_def)
apply(wp modify_wp dxo_wp_weak | simp)+
apply (simp add: trans_state_update[symmetric] del: trans_state_update)
apply wp+
apply (clarsimp simp: not_less)
apply (clarsimp simp add: silc_inv_def)
apply (intro conjI impI allI)
apply (fastforce simp: obj_at_def silc_inv_def dest: retype_addrs_subset_ptr_bits[simplified retype_addrs_def] simp: set_map image_def p_assoc_help power_sub)
defer
apply (fastforce simp: silc_dom_equiv_def equiv_for_def silc_inv_def dest: retype_addrs_subset_ptr_bits[simplified retype_addrs_def] simp: set_map image_def p_assoc_help power_sub)
apply(case_tac "a \<in> (\<lambda>p. ptr_add ptr (p * 2 ^ obj_bits_api type o_bits)) `
{0..<num_objects}")
apply clarsimp
apply(subgoal_tac "cap = NullCap")
apply(clarsimp simp: intra_label_cap_def cap_points_to_label_def)
apply(drule (1) cte_wp_at_eqD2)
apply fastforce
apply(erule cte_wp_atE)
subgoal by (fastforce simp: default_object_def empty_cnode_def split: apiobject_type.splits if_splits)
subgoal by (clarsimp simp: default_object_def default_tcb_def tcb_cap_cases_def split: apiobject_type.splits if_splits)
apply(subgoal_tac "cte_wp_at (op = cap) (a,b) s \<and> \<not> intra_label_cap aag (a,b) s")
apply(drule_tac x=a in spec, drule_tac x=b in spec, drule_tac x=cap in spec, simp)
apply(elim exE conjE, rename_tac la lb)
apply(rule_tac x=la in exI, simp, rule_tac x=lb in exI)
apply(simp add: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
apply(subgoal_tac "la \<notin> (\<lambda>p. ptr_add ptr (p * 2 ^ obj_bits_api type o_bits)) `
{0..<num_objects}")
apply(erule_tac t="(la,lb)" in cte_wp_atE)
apply(rule cte_wp_at_cteI)
apply fastforce
apply assumption
apply assumption
apply assumption
apply(rule cte_wp_at_tcbI)
apply fastforce
apply assumption
apply assumption
subgoal by (fastforce simp: silc_inv_def dest: retype_addrs_subset_ptr_bits[simplified retype_addrs_def]
simp: image_def p_assoc_help power_sub)
apply(rule conjI)
subgoal by (fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
apply(clarsimp simp: intra_label_cap_def cap_points_to_label_def)
apply(drule (1) cte_wp_at_eqD2)
apply(rule_tac x=capa in exI)
apply clarsimp
by (fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
lemma slots_holding_overlapping_caps_from_silc_inv:
assumes a: "\<lbrace> silc_inv aag st and P \<rbrace> f \<lbrace>\<lambda>_. silc_inv aag st \<rbrace>"
shows "\<lbrace> silc_inv aag st and (\<lambda> s. slot \<in> (slots_holding_overlapping_caps cap s) \<and> pasObjectAbs aag (fst slot) = SilcLabel) and P \<rbrace> f \<lbrace> \<lambda>_ s. slot \<in> (slots_holding_overlapping_caps cap s) \<rbrace>"
apply(simp add: valid_def split_def | intro impI allI ballI | elim conjE)+
apply(simp add: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
apply(erule subst[rotated], rule cte_wp_at_pspace')
apply(case_tac x, simp)
apply(drule use_valid[OF _ a])
apply simp
by (fastforce simp: silc_inv_def silc_dom_equiv_def elim: equiv_forE)
lemma slots_holding_overlapping_caps_eq:
assumes "Structures_A.obj_refs cap = Structures_A.obj_refs cap'"
assumes "cap_irqs cap = cap_irqs cap'"
shows
"slots_holding_overlapping_caps cap s = slots_holding_overlapping_caps cap' s"
using assms
apply(fastforce simp: slots_holding_overlapping_caps_def)
done
lemma detype_silc_inv:
"\<lbrace> silc_inv aag st and (K (\<forall>p\<in>S. is_subject aag p))\<rbrace>
modify (detype S)
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(wp modify_wp)
apply(clarsimp simp: silc_inv_def)
apply(rule conjI, fastforce)
apply(rule conjI)
apply (clarsimp simp: slots_holding_overlapping_caps_def intra_label_cap_def cap_points_to_label_def get_cap_cte_wp_at')
apply(drule (1) cte_wp_at_eqD2)
apply clarsimp
apply(drule_tac x=a in spec, drule_tac x=b in spec, drule_tac x=cap in spec)
apply simp
apply(erule impE)
apply fastforce
apply(elim exE conjE, rename_tac la lb lcap)
apply(rule_tac x=la in exI, simp, rule_tac x=lb in exI, rule_tac x=lcap in exI)
apply simp
apply fastforce
apply(clarsimp simp: silc_dom_equiv_def equiv_for_def detype_def)
done
lemma delete_objects_silc_inv:
"\<lbrace> silc_inv aag st and (K (\<forall>p\<in>ptr_range ptr bits. is_subject aag p))\<rbrace>
delete_objects ptr bits
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(rule hoare_gen_asm)
unfolding delete_objects_def
apply (wp detype_silc_inv | simp add: ptr_range_def)+
done
lemma set_cap_silc_inv_simple:
"\<lbrace> silc_inv aag st and cte_wp_at (\<lambda>cp. cap_irqs cp = cap_irqs cap
\<and> Structures_A.obj_refs cp = Structures_A.obj_refs cap) slot
and K (is_subject aag (fst slot))\<rbrace>
set_cap cap slot
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply (wp set_cap_silc_inv)
apply (clarsimp simp: cte_wp_at_caps_of_state)
apply (rule conjI; clarsimp)
apply (drule caps_of_state_cteD)
apply (frule(1) silc_invD)
apply (clarsimp simp: intra_label_cap_def)
apply (rule exI, rule conjI, assumption)
apply (simp add: cap_points_to_label_def)
apply (simp add: slots_holding_overlapping_caps_def)
apply (simp add: silc_inv_def)
done
lemma reset_untyped_cap_silc_inv:
"\<lbrace> silc_inv aag st and cte_wp_at is_untyped_cap slot
and invs and pas_refined aag
and (\<lambda>s. descendants_of slot (cdt s) = {})
and K (is_subject aag (fst slot))\<rbrace>
reset_untyped_cap slot
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply (rule hoare_gen_asm)
apply (simp add: reset_untyped_cap_def cong: if_cong)
apply (rule validE_valid, rule hoare_pre)
apply (wp set_cap_silc_inv_simple | simp add: unless_def)+
apply (rule valid_validE, rule_tac Q="\<lambda>_. cte_wp_at is_untyped_cap slot
and silc_inv aag st" in hoare_strengthen_post)
apply (rule validE_valid, rule mapME_x_inv_wp, rule hoare_pre)
apply (wp mapME_x_inv_wp preemption_point_inv set_cap_cte_wp_at
set_cap_silc_inv_simple | simp)+
apply (clarsimp simp: cte_wp_at_caps_of_state is_cap_simps)
apply simp
apply (wp hoare_vcg_const_imp_lift delete_objects_silc_inv get_cap_wp
set_cap_silc_inv_simple
| simp)+
apply (clarsimp simp: cte_wp_at_caps_of_state is_cap_simps bits_of_def)
apply (frule(1) cap_auth_caps_of_state)
apply (clarsimp simp: aag_cap_auth_def aag_has_Control_iff_owns
ptr_range_def[symmetric])
apply (frule if_unsafe_then_capD[OF caps_of_state_cteD], clarsimp+)
apply (drule ex_cte_cap_protects[OF _ _ _ _ order_refl], erule caps_of_state_cteD)
apply (clarsimp simp: descendants_range_def2 empty_descendants_range_in)
apply clarsimp+
done
lemma reset_untyped_cap_untyped_cap:
"\<lbrace>cte_wp_at (\<lambda>cp. is_untyped_cap cp \<and> P True (untyped_range cp)) slot
and invs
and (\<lambda>s. descendants_of slot (cdt s) = {})\<rbrace>
reset_untyped_cap slot
\<lbrace>\<lambda>rv. cte_wp_at (\<lambda>cp. P (is_untyped_cap cp) (untyped_range cp)) slot\<rbrace>"
apply (simp add: reset_untyped_cap_def cong: if_cong)
apply (rule hoare_pre)
apply (wp set_cap_cte_wp_at | simp add: unless_def)+
apply (rule valid_validE, rule_tac Q="\<lambda>rv. cte_wp_at (\<lambda>cp. is_untyped_cap cp
\<and> is_untyped_cap cap
\<and> untyped_range cp = untyped_range cap
\<and> P True (untyped_range cp)) slot"
in hoare_strengthen_post)
apply (wp mapME_x_inv_wp preemption_point_inv set_cap_cte_wp_at
| simp | clarsimp simp: cte_wp_at_caps_of_state is_cap_simps bits_of_def
ptr_range_def[symmetric])+
apply (wp get_cap_wp)
apply (clarsimp simp: cte_wp_at_caps_of_state is_cap_simps ptr_range_def[symmetric])
apply (frule if_unsafe_then_capD[OF caps_of_state_cteD], clarsimp+)
apply (drule ex_cte_cap_protects[OF _ _ _ _ order_refl], erule caps_of_state_cteD)
apply (clarsimp simp: descendants_range_def2 empty_descendants_range_in)
apply clarsimp+
done
lemma invoke_untyped_silc_inv:
"\<lbrace> silc_inv aag st and invs and pas_refined aag
and ct_active and valid_untyped_inv ui
and K (authorised_untyped_inv aag ui)\<rbrace>
invoke_untyped ui
\<lbrace> \<lambda>_. silc_inv aag st \<rbrace>"
apply(rule hoare_gen_asm)
apply (rule hoare_pre)
apply (rule_tac Q="\<lambda>_. silc_inv aag st
and cte_wp_at (\<lambda>cp. is_untyped_cap cp \<longrightarrow> (\<forall>x \<in> untyped_range cp.
is_subject aag x)) (case ui of Invocations_A.Retype src_slot _ _ _ _ _ _ _ \<Rightarrow>
src_slot)" in hoare_strengthen_post)
apply (rule invoke_untyped_Q)
apply (rule hoare_pre, wp create_cap_silc_inv create_cap_pas_refined)
apply (clarsimp simp: authorised_untyped_inv_def)
apply (auto simp: cte_wp_at_caps_of_state)[1]
apply ((wp | simp)+)[1]
apply (rule hoare_pre)
apply (wp retype_region_silc_inv retype_cte_wp_at | simp)+
apply clarsimp
apply (strengthen range_cover_le[mk_strg I E])
apply (clarsimp simp: cte_wp_at_caps_of_state)
apply (simp add: invs_valid_pspace)
apply (erule ball_subset)
apply (simp add: word_and_le2 field_simps)
apply (rule hoare_pre)
apply (wp set_cap_silc_inv_simple set_cap_cte_wp_at)
apply (cases ui, clarsimp simp: cte_wp_at_caps_of_state is_cap_simps
split del: if_split cong: if_cong)
apply (clarsimp simp: authorised_untyped_inv_def)
apply (wp reset_untyped_cap_silc_inv reset_untyped_cap_untyped_cap)
apply simp
apply (cases ui, clarsimp simp: cte_wp_at_caps_of_state
authorised_untyped_inv_def)
apply (frule(1) cap_auth_caps_of_state)
apply (clarsimp simp: aag_cap_auth_def aag_has_Control_iff_owns)
done
lemma perform_page_table_invocation_silc_ionv_get_cap_helper:
"\<lbrace>silc_inv aag st and cte_wp_at (is_pt_cap or is_pg_cap) xa\<rbrace>
get_cap xa
\<lbrace>(\<lambda>capa s.
(\<not> cap_points_to_label aag
(ArchObjectCap $ update_map_data capa None)
(pasObjectAbs aag (fst xa)) \<longrightarrow>
(\<exists>lslot.
lslot
\<in> FinalCaps.slots_holding_overlapping_caps
(ArchObjectCap $ update_map_data capa None)
s \<and>
pasObjectAbs aag (fst lslot) = SilcLabel))) \<circ> the_arch_cap\<rbrace>"
apply(wp get_cap_wp)
apply clarsimp
apply(drule cte_wp_at_eqD)
apply(clarify)
apply(drule (1) cte_wp_at_eqD2)
apply(case_tac cap, simp_all add: is_pg_cap_def is_pt_cap_def)
apply(clarsimp simp: cap_points_to_label_def update_map_data_def split: arch_cap.splits)
apply(drule silc_invD)
apply assumption
apply(fastforce simp: intra_label_cap_def cap_points_to_label_def)
apply(fastforce simp: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
apply(drule silc_invD)
apply assumption
apply(fastforce simp: intra_label_cap_def cap_points_to_label_def)
apply(fastforce simp: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
done
lemmas perform_page_table_invocation_silc_inv_get_cap_helper' =
perform_page_table_invocation_silc_ionv_get_cap_helper
[simplified o_def fun_app_def]
lemma mapM_x_swp_store_pte_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace> mapM_x (swp store_pte A) slots
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(wp mapM_x_wp[OF _ subset_refl] | simp add: swp_def)+
done
lemma is_arch_diminished_pt_is_pt_or_pg_cap:
"cte_wp_at (is_arch_diminished (ArchObjectCap (PageTableCap xa xb))) slot s
\<Longrightarrow> cte_wp_at (\<lambda>a. is_pt_cap a \<or> is_pg_cap a) slot s"
apply(erule cte_wp_at_weakenE)
apply (clarsimp simp: is_arch_diminished_def diminished_def mask_cap_def cap_rights_update_def split: cap.splits arch_cap.splits simp: acap_rights_update_def acap_rights_def)
apply(case_tac c, simp_all)[1]
apply(rename_tac arch_cap)
apply(drule_tac x=arch_cap in spec)
apply(case_tac arch_cap, simp_all add: is_pt_cap_def)[1]
done
lemma is_arch_diminished_pg_is_pt_or_pg_cap:
"cte_wp_at (is_arch_diminished (ArchObjectCap (PageCap dev x xa xb xc))) slot s
\<Longrightarrow> cte_wp_at (\<lambda>a. is_pt_cap a \<or> is_pg_cap a) slot s"
apply(erule cte_wp_at_weakenE)
apply (clarsimp simp: is_arch_diminished_def diminished_def mask_cap_def cap_rights_update_def split: cap.splits arch_cap.splits simp: acap_rights_update_def acap_rights_def)
apply(case_tac c, simp_all)[1]
apply(rename_tac arch_cap)
apply(drule_tac x=arch_cap in spec)
apply(case_tac arch_cap, simp_all add: is_pg_cap_def)[1]
done
lemma is_arch_update_overlaps:
"\<lbrakk>cte_wp_at (\<lambda>c. is_arch_update cap c) slot s;
\<not> cap_points_to_label aag cap l\<rbrakk>
\<Longrightarrow> slot \<in> slots_holding_overlapping_caps cap s"
apply(clarsimp simp: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
apply(erule cte_wp_at_weakenE)
apply(clarsimp simp: is_arch_update_def)
apply(clarsimp simp: cap_master_cap_def split: cap.splits arch_cap.splits simp: cap_points_to_label_def)
done
lemma perform_page_table_invocation_silc_inv:
"\<lbrace>silc_inv aag st and valid_pti blah and K (authorised_page_table_inv aag blah)\<rbrace>
perform_page_table_invocation blah
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding perform_page_table_invocation_def
apply(rule hoare_pre)
apply(wp set_cap_silc_inv
perform_page_table_invocation_silc_inv_get_cap_helper'[where st=st] mapM_x_wp[OF _ subset_refl]
| wpc | simp only: o_def fun_app_def K_def swp_def)+
apply clarsimp
apply(clarsimp simp: valid_pti_def authorised_page_table_inv_def split: page_table_invocation.splits)
apply(rule conjI)
apply(clarsimp)
defer
apply(fastforce simp: silc_inv_def)
apply(fastforce dest: is_arch_diminished_pt_is_pt_or_pg_cap simp: silc_inv_def)
apply(drule_tac slot="(aa,ba)" in overlapping_slots_have_labelled_overlapping_caps[rotated])
apply(fastforce)
apply(fastforce elim: is_arch_update_overlaps[rotated] cte_wp_at_weakenE)
apply fastforce
done
lemma perform_page_directory_invocation_silc_inv:
"\<lbrace>silc_inv aag st\<rbrace>
perform_page_directory_invocation blah
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding perform_page_directory_invocation_def
apply (cases blah)
apply (wp | simp)+
done
lemma as_user_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace>
as_user t f
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding as_user_def
apply(rule silc_inv_pres)
apply(wp set_object_wp | simp add: split_def)+
apply (clarsimp)
apply(fastforce simp: silc_inv_def dest: get_tcb_SomeD simp: obj_at_def is_cap_table_def)
apply(wp set_object_wp | simp add: split_def)+
apply(case_tac "t = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(erule notE)
apply(erule cte_wp_atE)
apply(fastforce simp: obj_at_def)
apply(drule get_tcb_SomeD)
apply(rule cte_wp_at_tcbI)
apply(simp)
apply assumption
apply (fastforce simp: tcb_cap_cases_def split: if_splits)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
crunch silc_inv[wp]: store_word_offs "silc_inv aag st"
crunch kheap[wp]: store_word_offs "\<lambda> s. P (kheap s x)"
crunch cte_wp_at'[wp]: store_word_offs "\<lambda> s. Q (cte_wp_at P slot s)"
(wp: crunch_wps simp: crunch_simps)
lemma set_mrs_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace>
set_mrs a b c
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding set_mrs_def
apply(rule silc_inv_pres)
apply(wp crunch_wps set_object_wp | wpc | simp add: crunch_simps split del: if_split)+
apply (clarsimp)
apply(fastforce simp: silc_inv_def dest: get_tcb_SomeD simp: obj_at_def is_cap_table_def)
apply(wp crunch_wps set_object_wp | wpc | simp add: crunch_simps split del: if_split)+
apply(case_tac "a = fst slot")
apply(clarsimp split: kernel_object.splits cong: conj_cong)
apply(erule notE)
apply(erule cte_wp_atE)
apply(fastforce simp: obj_at_def)
apply(drule get_tcb_SomeD)
apply(rule cte_wp_at_tcbI)
apply(simp)
apply assumption
apply (fastforce simp: tcb_cap_cases_def split: if_splits)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
crunch silc_inv[wp]: update_waiting_ntfn, set_message_info, invalidate_tlb_by_asid "silc_inv aag st"
lemma send_signal_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace> send_signal param_a param_b \<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding send_signal_def
apply (wp get_ntfn_wp gts_wp cancel_ipc_indirect_silc_inv | wpc | simp)+
apply (clarsimp simp: receive_blocked_def pred_tcb_at_def obj_at_def)
done
lemma perform_page_invocation_silc_inv:
"\<lbrace>silc_inv aag st and valid_page_inv blah and K (authorised_page_inv aag blah)\<rbrace>
perform_page_invocation blah
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding perform_page_invocation_def
apply(rule hoare_pre)
apply(wp mapM_wp[OF _ subset_refl] set_cap_silc_inv
mapM_x_wp[OF _ subset_refl]
perform_page_table_invocation_silc_inv_get_cap_helper'[where st=st]
hoare_vcg_all_lift hoare_vcg_if_lift static_imp_wp | wpc | simp only: swp_def o_def fun_app_def K_def
|wp_once hoare_drop_imps)+
apply (clarsimp simp: valid_page_inv_def authorised_page_inv_def
split: page_invocation.splits)
apply(intro allI impI conjI)
apply(drule_tac slot="(aa,bb)" in overlapping_slots_have_labelled_overlapping_caps[rotated])
apply(fastforce)
apply(fastforce elim: is_arch_update_overlaps[rotated] cte_wp_at_weakenE)
apply fastforce
apply(fastforce simp: silc_inv_def)
apply(drule_tac slot="(aa,bb)" in overlapping_slots_have_labelled_overlapping_caps[rotated])
apply(fastforce)
apply(fastforce elim: is_arch_update_overlaps[rotated] cte_wp_at_weakenE)
apply fastforce
apply(fastforce simp: silc_inv_def)
apply(fastforce dest: is_arch_diminished_pg_is_pt_or_pg_cap simp: silc_inv_def)
done
lemma blah: "\<lbrace>\<lambda>s. P ((cdt s)(x := (f (cdt s))))\<rbrace>
set_cap cap dest
\<lbrace>\<lambda>rv s.
P ((cdt s)(x := (f (cdt s))))\<rbrace>"
apply (rule set_cap_mdb_inv)
done
lemma cap_insert_silc_inv':
"\<lbrace>silc_inv aag st and K (is_subject aag (fst dest) \<and> is_subject aag (fst src) \<and> cap_points_to_label aag cap (pasSubject aag))\<rbrace>
cap_insert cap src dest
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding cap_insert_def
apply (wp set_cap_silc_inv hoare_vcg_ex_lift set_untyped_cap_as_full_slots_holding_overlapping_caps_other[where aag=aag] get_cap_wp update_cdt_silc_inv set_cap_caps_of_state2 set_untyped_cap_as_full_cdt_is_original_cap static_imp_wp | simp split del: if_split)+
apply (intro allI impI conjI)
apply clarsimp
apply(fastforce dest: silc_invD simp: intra_label_cap_def)
apply(clarsimp simp: silc_inv_def)
apply (fastforce dest!: silc_inv_all_children simp: all_children_def simp del: split_paired_All)
done
lemma intra_label_cap_pres':
assumes cte: "\<And> P. \<lbrace> \<lambda> s. cte_wp_at P slot s \<and> R s \<rbrace> f \<lbrace>\<lambda> _. cte_wp_at P slot \<rbrace>"
shows "\<lbrace> intra_label_cap aag slot and cte_wp_at Q slot and R \<rbrace> f \<lbrace>\<lambda> _s. (intra_label_cap aag slot s) \<rbrace>"
apply(clarsimp simp: valid_def intra_label_cap_def)
apply(drule cte_wp_at_eqD)
apply(elim exE conjE, rename_tac cap')
apply(subgoal_tac "cap' = cap", blast)
apply(drule use_valid[OF _ cte], fastforce)
apply(rule_tac s=b in cte_wp_at_eqD2, auto)
done
lemma max_free_index_update_intra_label_cap[wp]:
"\<lbrace>intra_label_cap aag slot and cte_wp_at (op = cap) slot\<rbrace>
set_cap (max_free_index_update cap) slot
\<lbrace>\<lambda>rv s. intra_label_cap aag slot s\<rbrace>"
unfolding set_cap_def
apply (wp set_object_wp get_object_wp | wpc| simp add: split_def)+
apply(clarsimp simp: intra_label_cap_def cap_points_to_label_def)
apply(fastforce elim: cte_wp_atE)
done
lemma get_cap_slots_holding_overlapping_caps:
"\<lbrace>silc_inv aag st\<rbrace> get_cap slot
\<lbrace>\<lambda>cap s. (\<not> cap_points_to_label aag cap (pasObjectAbs aag (fst slot)) \<longrightarrow>
(\<exists>a. (\<exists>b. (a, b) \<in> FinalCaps.slots_holding_overlapping_caps cap s) \<and>
pasObjectAbs aag a = SilcLabel))\<rbrace>"
apply(wp get_cap_wp)
apply(fastforce dest: silc_invD simp: intra_label_cap_def)
done
lemma get_cap_cte_wp_at_triv:
"\<lbrace> \<top> \<rbrace> get_cap slot \<lbrace>\<lambda> rv s. cte_wp_at (op = rv) slot s \<rbrace>"
apply(wp get_cap_wp, simp)
done
lemma get_cap_valid_max_free_index_update:
"\<lbrace> \<lambda> s. \<exists> cap. cte_wp_at (op = cap) slot s \<and> valid_cap cap s \<and> is_untyped_cap cap \<rbrace>
get_cap slot
\<lbrace>\<lambda>rv s. s \<turnstile> max_free_index_update rv\<rbrace>"
apply(wp get_cap_wp)
apply clarsimp
apply(drule (1) cte_wp_at_eqD2, clarsimp)
done
lemma get_cap_perform_asid_control_invocation_helper:
"\<lbrace>\<lambda> s. (\<exists> cap. cte_wp_at (op = cap) x2 s \<and> valid_cap cap s \<and> is_untyped_cap cap) \<and> R\<rbrace>
get_cap x2
\<lbrace>\<lambda>rv s. free_index_of rv \<le> max_free_index (untyped_sz_bits rv) \<and>
is_untyped_cap rv \<and>
max_free_index (untyped_sz_bits rv) \<le> 2 ^ cap_bits rv \<and> R\<rbrace>"
apply(wp get_cap_wp)
apply clarsimp
apply(drule (1) cte_wp_at_eqD2)
apply(case_tac capa, simp_all add: max_free_index_def free_index_of_def valid_cap_simps)
done
lemma retype_region_cte_wp_at_other':
"\<lbrace> cte_wp_at P slot and K ((fst slot) \<notin> set (retype_addrs ptr ty n us)) \<rbrace>
retype_region ptr n us ty dev
\<lbrace> \<lambda>_. cte_wp_at P slot \<rbrace>"
apply(rule hoare_gen_asm)
apply(clarsimp simp: valid_def)
apply(subst cte_wp_at_pspace')
prefer 2
apply assumption
apply(erule use_valid)
apply(simp only: retype_region_def retype_addrs_def
foldr_upd_app_if fun_app_def K_bind_def)
apply(wp modify_wp | simp)+
apply (clarsimp simp: not_less retype_addrs_def)
done
lemma untyped_caps_are_intra_label:
"\<lbrakk>cte_wp_at is_untyped_cap slot s\<rbrakk>
\<Longrightarrow> intra_label_cap aag slot s"
apply(clarsimp simp: intra_label_cap_def cap_points_to_label_def)
apply(drule (1) cte_wp_at_eqD2)
apply(case_tac cap, simp_all)
done
lemma perform_asid_control_invocation_silc_inv:
notes blah[simp del] = atLeastAtMost_iff atLeastatMost_subset_iff atLeastLessThan_iff
shows
"\<lbrace>silc_inv aag st and valid_aci blah and invs and K (authorised_asid_control_inv aag blah)\<rbrace>
perform_asid_control_invocation blah
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(rule hoare_gen_asm)
unfolding perform_asid_control_invocation_def
apply(rule hoare_pre)
apply (wp modify_wp cap_insert_silc_inv' retype_region_silc_inv[where sz=pageBits]
set_cap_silc_inv get_cap_slots_holding_overlapping_caps[where st=st]
delete_objects_silc_inv static_imp_wp
| wpc | simp )+
apply (clarsimp simp: authorised_asid_control_inv_def silc_inv_def valid_aci_def ptr_range_def page_bits_def)
apply(rule conjI)
apply(clarsimp simp: range_cover_def obj_bits_api_def default_arch_object_def asid_bits_def pageBits_def)
apply(rule of_nat_inverse)
apply simp
apply(drule is_aligned_neg_mask_eq'[THEN iffD1, THEN sym])
apply(erule_tac t=x in ssubst)
apply(simp add: mask_AND_NOT_mask)
apply simp
apply(simp add: is_aligned_neg_mask_eq' p_assoc_help)
apply(clarsimp simp: cap_points_to_label_def)
apply(erule bspec)
apply(fastforce intro: is_aligned_no_wrap' simp: is_aligned_neg_mask_eq' blah)
done
lemma perform_asid_pool_invocation_silc_inv:
"\<lbrace>silc_inv aag st and K (authorised_asid_pool_inv aag blah)\<rbrace>
perform_asid_pool_invocation blah
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(rule hoare_gen_asm)
unfolding perform_asid_pool_invocation_def
apply(rule hoare_pre)
apply(wp set_cap_silc_inv get_cap_wp | wpc)+
apply clarsimp
apply(rule conjI, intro impI)
apply(drule silc_invD)
apply assumption
apply(fastforce simp: intra_label_cap_def simp: cap_points_to_label_def)
apply(clarsimp simp: slots_holding_overlapping_caps_def)
apply(fastforce simp: authorised_asid_pool_inv_def silc_inv_def)
done
lemma arch_perform_invocation_silc_inv:
"\<lbrace>silc_inv aag st and invs and valid_arch_inv ai and K (authorised_arch_inv aag ai)\<rbrace>
arch_perform_invocation ai
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding arch_perform_invocation_def
apply(rule hoare_pre)
apply(wp perform_page_table_invocation_silc_inv
perform_page_directory_invocation_silc_inv
perform_page_invocation_silc_inv
perform_asid_control_invocation_silc_inv
perform_asid_pool_invocation_silc_inv
| wpc)+
apply(clarsimp simp: authorised_arch_inv_def valid_arch_inv_def split: arch_invocation.splits)
done
lemma interrupt_derived_ntfn_cap_identical_refs:
"\<lbrakk>interrupt_derived cap cap'; is_ntfn_cap cap\<rbrakk> \<Longrightarrow>
Structures_A.obj_refs cap = Structures_A.obj_refs cap' \<and>
cap_irqs cap = cap_irqs cap'"
apply(case_tac cap)
apply(simp_all add: interrupt_derived_def cap_master_cap_def split: cap.splits)
done
lemma subject_not_silc: "is_subject aag x \<Longrightarrow> silc_inv aag st s \<Longrightarrow> pasObjectAbs aag x \<noteq> SilcLabel"
apply (clarsimp simp add: silc_inv_def)
done
lemma cap_insert_silc_inv'':
"\<lbrace>silc_inv aag st and (\<lambda> s. \<not> cap_points_to_label aag cap (pasObjectAbs aag (fst dest)) \<longrightarrow>
(\<exists> lslot. lslot \<in> slots_holding_overlapping_caps cap s \<and>
pasObjectAbs aag (fst lslot) = SilcLabel)) and K (is_subject aag (fst src) \<and> is_subject aag (fst dest))\<rbrace>
cap_insert cap src dest
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding cap_insert_def
apply (wp set_cap_silc_inv hoare_vcg_ex_lift set_untyped_cap_as_full_slots_holding_overlapping_caps_other[where aag=aag] get_cap_wp update_cdt_silc_inv set_cap_caps_of_state2 set_untyped_cap_as_full_cdt_is_original_cap static_imp_wp | simp split del: if_split)+
apply (intro impI conjI allI)
apply clarsimp
apply(fastforce simp: silc_inv_def)
apply clarsimp
apply(drule_tac cap=capa in silc_invD)
apply assumption
apply(fastforce simp: intra_label_cap_def)
apply fastforce
apply(fastforce simp: silc_inv_def)
apply (elim conjE)
apply (drule(1) subject_not_silc)+
apply (subgoal_tac "\<forall>b. all_children
(\<lambda>x. pasObjectAbs aag (fst x) = SilcLabel)
(\<lambda>a. if a = dest
then if b
then Some src else cdt s src
else cdt s a)")
apply simp
apply (intro allI)
apply (drule silc_inv_all_children)
apply (simp add: all_children_def del: split_paired_All)
apply fastforce
done
lemma cap_delete_one_cte_wp_at_other:
"\<lbrace> cte_wp_at P slot and K (slot \<noteq> irq_slot) \<rbrace>
cap_delete_one irq_slot
\<lbrace>\<lambda>rv s. cte_wp_at P slot s \<rbrace>"
unfolding cap_delete_one_def
apply(wp hoare_unless_wp empty_slot_cte_wp_elsewhere get_cap_wp | simp)+
done
lemma invoke_irq_handler_silc_inv:
"\<lbrace>silc_inv aag st and pas_refined aag and irq_handler_inv_valid blah and K (authorised_irq_hdl_inv aag blah) \<rbrace> invoke_irq_handler blah \<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(rule hoare_gen_asm)
apply(case_tac blah)
apply(wp cap_insert_silc_inv'' cap_delete_one_silc_inv cap_delete_one_cte_wp_at_other static_imp_wp
hoare_vcg_ex_lift slots_holding_overlapping_caps_from_silc_inv[where aag=aag and st=st]
| simp add: authorised_irq_hdl_inv_def get_irq_slot_def conj_comms)+
apply (clarsimp simp: pas_refined_def irq_map_wellformed_aux_def)
apply (drule cte_wp_at_eqD)
apply (elim exE conjE, rename_tac cap')
apply (drule_tac cap=cap' in silc_invD)
apply assumption
apply(fastforce simp: intra_label_cap_def cap_points_to_label_def interrupt_derived_ntfn_cap_identical_refs)
apply(fastforce simp: slots_holding_overlapping_caps_def2 ctes_wp_at_def interrupt_derived_ntfn_cap_identical_refs)
apply(wp cap_delete_one_silc_inv | simp add: pas_refined_def irq_map_wellformed_aux_def authorised_irq_hdl_inv_def)+
done
lemma new_irq_handler_caps_are_intra_label:
"\<lbrakk>cte_wp_at (op = (IRQControlCap)) slot s; pas_refined aag s; is_subject aag (fst slot)\<rbrakk>
\<Longrightarrow> cap_points_to_label aag (IRQHandlerCap irq) (pasSubject aag)"
apply(clarsimp simp: cap_points_to_label_def)
apply(frule cap_cur_auth_caps_of_state[rotated])
apply assumption
apply(simp add: cte_wp_at_caps_of_state)
apply(clarsimp simp: aag_cap_auth_def cap_links_irq_def)
apply(blast intro: aag_Control_into_owns_irq)
done
lemma invoke_irq_control_silc_inv:
"\<lbrace>silc_inv aag st and pas_refined aag and irq_control_inv_valid blah and K (authorised_irq_ctl_inv aag blah) \<rbrace> invoke_irq_control blah \<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(rule hoare_gen_asm)
apply(case_tac blah)
apply(wp cap_insert_silc_inv'' hoare_vcg_ex_lift slots_holding_overlapping_caps_lift
| simp add: authorised_irq_ctl_inv_def)+
apply(fastforce dest: new_irq_handler_caps_are_intra_label)
apply simp
done
crunch silc_inv[wp]: receive_signal "silc_inv aag st"
lemma setup_caller_cap_silc_inv:
"\<lbrace>silc_inv aag st and K (is_subject aag sender \<and> is_subject aag receiver)\<rbrace>
setup_caller_cap sender receiver
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding setup_caller_cap_def
apply(wp cap_insert_silc_inv'' hoare_vcg_imp_lift hoare_vcg_ex_lift
slots_holding_overlapping_caps_from_silc_inv[where aag=aag and st=st and P="\<top>"] | simp)+
apply(rule disjI1)
apply(auto simp: cap_points_to_label_def)
done
crunch silc_inv[wp]: set_extra_badge "silc_inv aag st"
lemma imp_ball_lemma:
"(R y \<longrightarrow> (\<forall>x\<in>S. P y x)) = (\<forall>x\<in>S. R y \<longrightarrow> P y x)"
apply auto
done
lemma derive_cap_silc:
"\<lbrace> \<lambda> s. (\<not> cap_points_to_label aag cap l) \<longrightarrow> (R (slots_holding_overlapping_caps cap s)) \<rbrace>
derive_cap slot cap
\<lbrace> \<lambda> cap' s. (\<not> cap_points_to_label aag cap' l) \<longrightarrow> (R (slots_holding_overlapping_caps cap' s)) \<rbrace>,-"
apply(rule hoare_pre)
apply(simp add: derive_cap_def)
apply(wp | wpc | simp add: split_def arch_derive_cap_def)+
apply(clarsimp simp: cap_points_to_label_def)
apply (auto simp: slots_holding_overlapping_caps_def)
done
lemma transfer_caps_silc_inv:
"\<lbrace>silc_inv aag st and valid_objs and valid_mdb and pas_refined aag
and (\<lambda> s. (\<forall>x\<in>set caps.
s \<turnstile> fst x) \<and>
(\<forall>x\<in>set caps.
cte_wp_at
(\<lambda>cp. fst x \<noteq> NullCap \<longrightarrow>
cp = fst x)
(snd x) s \<and>
real_cte_at (snd x) s)) and
K (is_subject aag receiver \<and> (\<forall>cap\<in>set caps.
is_subject aag (fst (snd cap))))\<rbrace>
transfer_caps mi caps endpoint receiver receive_buffer
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply (rule hoare_gen_asm)
apply (simp add: transfer_caps_def)
apply (wpc | wp)+
apply (rule_tac P = "\<forall>x \<in> set dest_slots. is_subject aag (fst x)" in hoare_gen_asm)
apply (wp transfer_caps_loop_pres_dest cap_insert_silc_inv)
apply(fastforce simp: silc_inv_def)
apply(wp get_receive_slots_authorised hoare_vcg_all_lift hoare_vcg_imp_lift | simp)+
apply(fastforce elim: cte_wp_at_weakenE)
done
crunch silc_inv[wp]: copy_mrs, set_message_info "silc_inv aag st"
(wp: crunch_wps)
lemma do_normal_transfer_silc_inv:
"\<lbrace>silc_inv aag st and valid_objs and valid_mdb and pas_refined aag and
K (grant \<longrightarrow> is_subject aag sender \<and> is_subject aag receiver)\<rbrace>
do_normal_transfer sender send_buffer ep badge grant receiver recv_buffer
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding do_normal_transfer_def
apply(case_tac grant)
apply ((wp transfer_caps_silc_inv copy_mrs_cte_wp_at hoare_vcg_ball_lift lec_valid_cap' lookup_extra_caps_authorised
| simp)+)[1]
apply simp
apply(wp transfer_caps_empty_inv | simp)+
done
crunch silc_inv[wp]: do_fault_transfer, complete_signal "silc_inv aag st"
(* doesn't need sym_refs *)
lemma valid_ep_recv_dequeue':
"\<lbrakk> ko_at (Endpoint (Structures_A.endpoint.RecvEP (t # ts))) epptr s;
valid_objs s\<rbrakk>
\<Longrightarrow> valid_ep (case ts of [] \<Rightarrow> Structures_A.endpoint.IdleEP
| b # bs \<Rightarrow> Structures_A.endpoint.RecvEP ts) s"
unfolding valid_objs_def valid_obj_def valid_ep_def obj_at_def
apply (drule bspec)
apply (auto split: list.splits)
done
lemma do_ipc_transfer_silc_inv:
"\<lbrace>silc_inv aag st and valid_objs and valid_mdb and pas_refined aag and
K (grant \<longrightarrow> is_subject aag sender \<and> is_subject aag receiver)\<rbrace>
do_ipc_transfer sender ep badge grant receiver
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding do_ipc_transfer_def
apply (wp do_normal_transfer_silc_inv hoare_vcg_all_lift | wpc | wp_once hoare_drop_imps)+
apply clarsimp
done
lemma send_ipc_silc_inv:
"\<lbrace>silc_inv aag st and valid_objs and valid_mdb and pas_refined aag and
sym_refs \<circ> state_refs_of and
(\<lambda>s. \<exists>ep. ko_at (Endpoint ep) epptr s \<and>
(can_grant \<longrightarrow>
(\<forall>x\<in>ep_q_refs_of ep. (\<lambda>(t, rt). rt = EPRecv \<longrightarrow> is_subject aag t) x)))
and K (can_grant \<longrightarrow> is_subject aag thread)\<rbrace>
send_ipc block call badge can_grant thread epptr
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding send_ipc_def
apply (wp setup_caller_cap_silc_inv | wpc | simp)+
apply(rename_tac xs word ys recv_state)
apply(rule_tac Q="\<lambda> r s. (can_grant \<longrightarrow> is_subject aag thread \<and> is_subject aag (hd xs)) \<and> silc_inv aag st s" in hoare_strengthen_post)
apply simp
apply(wp do_ipc_transfer_silc_inv | wpc | simp)+
apply(wp_once hoare_drop_imps)
apply (wp get_endpoint_wp)+
apply clarsimp
apply(rule conjI)
apply(fastforce simp: obj_at_def ep_q_refs_of_def)
apply(clarsimp simp: valid_ep_recv_dequeue' obj_at_def)
done
lemma receive_ipc_base_silc_inv:
notes do_nbrecv_failed_transfer_def[simp]
shows "\<lbrace>silc_inv aag st and valid_objs and valid_mdb and pas_refined aag and
sym_refs \<circ> state_refs_of and ko_at (Endpoint ep) epptr and
K (is_subject aag receiver \<and> (pasSubject aag, Receive, pasObjectAbs aag epptr) \<in> pasPolicy aag)\<rbrace>
receive_ipc_base aag receiver ep epptr rights is_blocking
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply (clarsimp simp: thread_get_def get_thread_state_def cong: endpoint.case_cong)
apply (rule hoare_pre)
apply (wp setup_caller_cap_silc_inv
| wpc | simp split del: if_split)+
apply (rename_tac list tcb data)
apply(rule_tac Q="\<lambda> r s. (sender_can_grant data \<longrightarrow> is_subject aag receiver \<and> is_subject aag (hd list)) \<and> silc_inv aag st s" in hoare_strengthen_post)
apply(wp do_ipc_transfer_silc_inv hoare_vcg_all_lift | wpc | simp)+
apply(wp hoare_vcg_imp_lift [OF set_endpoint_get_tcb, unfolded disj_not1]
hoare_vcg_all_lift get_endpoint_wp
| wpc)+
apply (clarsimp simp: conj_comms)
apply(rule conjI)
defer
apply(drule valid_objsE)
apply(fastforce simp: obj_at_def)
prefer 2
apply assumption
apply(clarsimp simp: valid_obj_def)
apply(clarsimp simp: valid_ep_def split: list.splits)
apply(rule conjI)
apply(erule bspec)
apply(fastforce intro: hd_tl_in_set)
apply(rule conjI)
apply(fastforce dest: subsetD[OF set_tl_subset])
apply(case_tac x, auto)[1]
(* clagged from Ipc_AC.receive_ipc_integrity_autarch *)
apply (subgoal_tac "epptr = xa")
prefer 2
apply (frule_tac p = epptr in sym_refs_obj_atD, assumption)
apply (clarsimp)
apply (drule (1) bspec [OF _ hd_in_set])
apply (clarsimp simp: obj_at_def tcb_bound_refs_def2 dest!: get_tcb_SomeD)
apply clarsimp
apply (subgoal_tac "aag_has_auth_to aag Control (hd x)")
apply (fastforce simp add: pas_refined_refl dest!: aag_Control_into_owns)
apply (rule_tac ep = "pasObjectAbs aag epptr" in aag_wellformed_grant_Control_to_send [OF _ _ pas_refined_wellformed])
apply (rule_tac s = s in pas_refined_mem [OF sta_ts])
apply (clarsimp simp: tcb_at_def thread_states_def tcb_states_of_state_def dest!: st_tcb_at_tcb_at)
apply assumption+
done
lemma receive_ipc_silc_inv:
"\<lbrace>silc_inv aag st and valid_objs and valid_mdb and pas_refined aag and
sym_refs \<circ> state_refs_of and
K (is_subject aag receiver \<and>
(\<forall>epptr\<in>Access.obj_refs cap.
(pasSubject aag, Receive, pasObjectAbs aag epptr) \<in> pasPolicy aag))\<rbrace>
receive_ipc receiver cap is_blocking
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding receive_ipc_def
apply (rule hoare_gen_asm)
apply (simp del: AllowSend_def split: cap.splits)
apply clarsimp
apply (rule hoare_seq_ext[OF _ get_endpoint_sp])
apply (rule hoare_seq_ext[OF _ gbn_sp])
apply (case_tac ntfnptr, simp_all)
(* old receive case, not bound *)
apply (rule hoare_pre, wp receive_ipc_base_silc_inv, clarsimp)
apply (rule hoare_seq_ext[OF _ get_ntfn_sp])
apply (case_tac "isActive ntfn", simp_all)
(* new ntfn-binding case *)
apply (rule hoare_pre, wp, clarsimp)
(* old receive case, bound ntfn not active *)
apply (rule hoare_pre, wp receive_ipc_base_silc_inv, clarsimp)
done
lemma send_fault_ipc_silc_inv:
"\<lbrace>pas_refined aag and valid_objs and sym_refs \<circ> state_refs_of and valid_mdb and
silc_inv aag st and
K (valid_fault fault) and
K (is_subject aag thread)\<rbrace>
send_fault_ipc thread fault
\<lbrace>\<lambda>rv. silc_inv aag st\<rbrace>"
apply(rule hoare_gen_asm)+
unfolding send_fault_ipc_def
apply(wp send_ipc_silc_inv thread_set_valid_objs thread_set_tcb_fault_update_valid_mdb
thread_set_fault_pas_refined thread_set_refs_trivial thread_set_obj_at_impossible
hoare_vcg_ex_lift
| wpc| simp add: Let_def split_def lookup_cap_def valid_tcb_fault_update split del: if_split)+
apply(rule_tac Q="\<lambda> handler_cap s. silc_inv aag st s \<and>
valid_objs s \<and> valid_mdb s \<and>
pas_refined aag s \<and>
sym_refs (state_refs_of s) \<and>
(\<forall>x xa xb.
handler_cap = EndpointCap x xa xb \<longrightarrow>
(AllowWrite \<in> xb \<and> AllowGrant \<in> xb \<longrightarrow> (\<exists>xa. ko_at (Endpoint xa) x s \<and>
(\<forall>x\<in>ep_q_refs_of xa.
snd x = EPRecv \<longrightarrow> is_subject aag (fst x)))))" in hoare_strengthen_post)
apply(wp get_cap_inv get_cap_auth_wp[where aag=aag])
apply fastforce
(* clagged from Ipc_AC.send_fault_ipc_pas_refined *)
apply wp
apply (rule_tac Q'="\<lambda>rv s. silc_inv aag st s \<and> pas_refined aag s
\<and> valid_objs s \<and> sym_refs (state_refs_of s)
\<and> valid_mdb s
\<and> is_subject aag (fst (fst rv))"
in hoare_post_imp_R[rotated])
apply clarsimp
apply (frule caps_of_state_valid_cap, assumption)
apply (clarsimp simp: valid_cap_simps obj_at_def is_ep)
apply (subgoal_tac "\<forall>auth. aag_has_auth_to aag auth x")
apply (erule (3) owns_ep_owns_receivers', simp add: obj_at_def, assumption)
apply (auto dest!: pas_refined_mem[OF sta_caps]
simp: cap_auth_conferred_def cap_rights_to_auth_def)[1]
apply (wp get_cap_auth_wp[where aag=aag] lookup_slot_for_thread_authorised
| simp add: add: lookup_cap_def split_def)+
done
crunch silc_inv[wp]: handle_fault "silc_inv aag st"
crunch silc_inv[wp]: do_reply_transfer "silc_inv aag st"
(wp: thread_set_tcb_fault_update_silc_inv crunch_wps ignore: set_object thread_set)
crunch silc_inv[wp]: reply_from_kernel "silc_inv aag st"
(wp: crunch_wps simp: crunch_simps)
lemma setup_reply_master_silc_inv:
"\<lbrace>silc_inv aag st and K (is_subject aag thread)\<rbrace> setup_reply_master thread \<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding setup_reply_master_def
apply (wp set_cap_silc_inv hoare_vcg_ex_lift slots_holding_overlapping_caps_from_silc_inv[where aag=aag and st=st and P="\<top>"] get_cap_wp static_imp_wp | simp)+
apply(clarsimp simp: cap_points_to_label_def silc_inv_def)
done
crunch silc_inv: restart "silc_inv aag st"
(wp: crunch_wps simp: crunch_simps)
crunch silc_inv: suspend "silc_inv aag st"
lemma same_object_as_cap_points_to_label:
"\<lbrakk>same_object_as a cap;
\<not> cap_points_to_label aag a (pasSubject aag)\<rbrakk>
\<Longrightarrow> \<not> cap_points_to_label aag cap (pasSubject aag)"
apply(simp add: same_object_as_def cap_points_to_label_def split: cap.splits)
apply(case_tac cap, simp_all)
apply(case_tac cap, simp_all)
apply(case_tac cap, simp_all)
apply(case_tac cap, simp_all)
subgoal for arch1 arch2 by (cases arch1; cases arch2; simp)
done
lemma same_object_as_slots_holding_overlapping_caps:
"\<lbrakk>same_object_as a cap;
\<not> cap_points_to_label aag a (pasSubject aag)\<rbrakk> \<Longrightarrow>
slots_holding_overlapping_caps cap s = slots_holding_overlapping_caps a s"
apply(simp add: same_object_as_def slots_holding_overlapping_caps_def2 ctes_wp_at_def split: cap.splits)
apply(case_tac cap, simp_all)
apply(case_tac cap, simp_all)
apply(case_tac cap, simp_all)
apply(case_tac cap, simp_all)
apply(case_tac cap, simp_all)
subgoal for arch1 arch2 by (cases arch1; cases arch2; simp)
done
lemma checked_cap_insert_silc_inv:
"\<lbrace>silc_inv aag st and K (is_subject aag (fst b) \<and> is_subject aag (fst e))\<rbrace>
check_cap_at a b (check_cap_at c d (cap_insert a b e))
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(wp cap_insert_silc_inv'' get_cap_wp | simp add: check_cap_at_def)+
apply clarsimp
apply(drule_tac cap=cap in silc_invD)
apply assumption
apply(clarsimp simp: intra_label_cap_def)
apply(fastforce dest: same_object_as_cap_points_to_label)
apply(fastforce dest: same_object_as_slots_holding_overlapping_caps)
done
lemma thread_set_tcb_ipc_buffer_update_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace>
thread_set (tcb_ipc_buffer_update blah) t
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
by (rule thread_set_silc_inv; simp add: tcb_cap_cases_def)
lemma thread_set_tcb_fault_handler_update_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace>
thread_set (tcb_fault_handler_update blah) t
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
by (rule thread_set_silc_inv; simp add: tcb_cap_cases_def)
lemma thread_set_tcb_fault_handler_update_invs:
"\<lbrace>invs and K (length a = word_bits)\<rbrace>
thread_set (tcb_fault_handler_update (\<lambda>y. a)) word
\<lbrace>\<lambda>rv s. invs s\<rbrace>"
apply(rule hoare_gen_asm)
apply(wp itr_wps | simp)+
done
lemma set_mcpriority_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace> set_mcpriority t mcp \<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding set_mcpriority_def
by (rule thread_set_silc_inv; simp add: tcb_cap_cases_def)
crunch silc_inv[wp]: bind_notification "silc_inv aag st"
lemma invoke_tcb_silc_inv:
notes static_imp_wp [wp]
static_imp_conj_wp [wp]
shows
"\<lbrace>silc_inv aag st and einvs and simple_sched_action and pas_refined aag and
Tcb_AI.tcb_inv_wf tinv and K (authorised_tcb_inv aag tinv)\<rbrace>
invoke_tcb tinv
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
including no_pre
apply(case_tac tinv)
apply((wp restart_silc_inv hoare_vcg_if_lift suspend_silc_inv mapM_x_wp[OF _ subset_refl] static_imp_wp
| wpc
| simp split del: if_split add: authorised_tcb_inv_def check_cap_at_def
| clarsimp)+)[3]
defer
apply((wp suspend_silc_inv restart_silc_inv | simp add: authorised_tcb_inv_def)+)[2]
(* NotificationControl *)
apply (rename_tac option)
apply (case_tac option)
apply ((wp | simp)+)[2]
(* just ThreadControl left *)
apply (simp add: split_def cong: option.case_cong)
apply (wp checked_cap_insert_silc_inv hoare_vcg_all_lift_R
hoare_vcg_all_lift hoare_vcg_const_imp_lift_R
cap_delete_silc_inv itr_wps(19) cap_insert_pas_refined
cap_delete_pas_refined cap_delete_deletes
cap_delete_valid_cap cap_delete_cte_at itr_wps(12)
itr_wps(14)
check_cap_inv2[where Q="\<lambda>_. valid_list"]
check_cap_inv2[where Q="\<lambda>_. valid_sched"]
check_cap_inv2[where Q="\<lambda>_. simple_sched_action"]
|wpc
|simp add: emptyable_def tcb_cap_cases_def tcb_cap_valid_def
tcb_at_st_tcb_at
|strengthen use_no_cap_to_obj_asid_strg)+
apply(rule hoare_pre)
apply(simp add: option_update_thread_def tcb_cap_cases_def
| wp hoare_vcg_all_lift
thread_set_tcb_fault_handler_update_invs
thread_set_pas_refined thread_set_emptyable
thread_set_valid_cap thread_set_not_state_valid_sched
thread_set_cte_at thread_set_no_cap_to_trivial
| wpc)+
apply (clarsimp simp: authorised_tcb_inv_def emptyable_def)
apply(clarsimp simp: is_cap_simps is_cnode_or_valid_arch_def is_valid_vtable_root_def | intro impI | rule conjI)+
done
lemma perform_invocation_silc_inv:
"\<lbrace>silc_inv aag st and valid_invocation iv and
authorised_invocation aag iv and einvs and simple_sched_action
and pas_refined aag and is_subject aag \<circ> cur_thread\<rbrace>
perform_invocation block call iv
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
including no_pre
apply(case_tac iv)
apply(wp invoke_untyped_silc_inv send_ipc_silc_inv
invoke_tcb_silc_inv invoke_cnode_silc_inv
invoke_irq_control_silc_inv
invoke_irq_handler_silc_inv
arch_perform_invocation_silc_inv
| simp add: authorised_invocation_def invs_valid_objs
invs_mdb invs_sym_refs
split_def
| blast)+
done
lemma handle_invocation_silc_inv:
"\<lbrace>silc_inv aag st and einvs and simple_sched_action and pas_refined aag and
is_subject aag \<circ> cur_thread and ct_active and domain_sep_inv (pasMaySendIrqs aag) st'\<rbrace>
handle_invocation calling blocking
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply (simp add: handle_invocation_def ts_Restart_case_helper split_def
liftE_liftM_liftME liftME_def bindE_assoc
split del: if_split)
apply(wp syscall_valid perform_invocation_silc_inv set_thread_state_runnable_valid_sched
set_thread_state_pas_refined decode_invocation_authorised
| simp split del: if_split)+
apply(rule_tac E="\<lambda>ft. silc_inv aag st and pas_refined aag and
valid_objs and
sym_refs \<circ> state_refs_of and
valid_mdb and
(\<lambda>y. valid_fault ft) and
(\<lambda>y. is_subject aag thread)" and R="Q" and Q=Q for Q in hoare_post_impErr)
apply(wp lookup_extra_caps_authorised lookup_extra_caps_auth
| simp)+
apply(rule_tac E="\<lambda>ft. silc_inv aag st and pas_refined aag and
valid_objs and
sym_refs \<circ> state_refs_of and
valid_mdb and
(\<lambda>y. valid_fault (CapFault x False ft)) and
(\<lambda>y. is_subject aag thread)" and R="Q" and Q=Q for Q in hoare_post_impErr)
apply (wp lookup_cap_and_slot_authorised
lookup_cap_and_slot_cur_auth
| simp)+
apply (auto intro: st_tcb_ex_cap simp: ct_in_state_def runnable_eq_active)
done
lemmas handle_send_silc_inv = handle_invocation_silc_inv[where calling=False, folded handle_send_def]
lemmas handle_call_silc_inv = handle_invocation_silc_inv[where calling=True and blocking=True, folded handle_call_def]
lemma cte_wp_at_caps_of_state':
"cte_wp_at (op = c) slot s \<Longrightarrow> caps_of_state s slot = Some c"
by(simp add: caps_of_state_def cte_wp_at_def)
lemma handle_reply_silc_inv:
"\<lbrace>silc_inv aag st and invs and pas_refined aag and
is_subject aag \<circ> cur_thread\<rbrace>
handle_reply
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(simp add: handle_reply_def)
apply (wp hoare_vcg_all_lift get_cap_wp | wpc )+
apply(clarsimp simp: invs_valid_objs invs_mdb)
apply(subst aag_cap_auth_Reply[symmetric], assumption)
apply(rule cap_cur_auth_caps_of_state)
apply(subst cte_wp_at_caps_of_state')
apply assumption
apply (rule refl)
apply assumption
by simp
crunch silc_inv: delete_caller_cap "silc_inv aag st"
lemma handle_recv_silc_inv:
"\<lbrace>silc_inv aag st and invs and pas_refined aag and
is_subject aag \<circ> cur_thread\<rbrace>
handle_recv is_blocking
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply (simp add: handle_recv_def Let_def lookup_cap_def split_def)
apply (wp hoare_vcg_all_lift get_ntfn_wp delete_caller_cap_silc_inv
receive_ipc_silc_inv
lookup_slot_for_thread_authorised
lookup_slot_for_thread_cap_fault
get_cap_auth_wp[where aag=aag]
| wpc | simp
| rule_tac Q="\<lambda>rv s. invs s \<and> pas_refined aag s \<and> is_subject aag thread
\<and> (pasSubject aag, Receive, pasObjectAbs aag x31) \<in> pasPolicy aag"
in hoare_strengthen_post, wp, clarsimp simp: invs_valid_objs invs_sym_refs)+
apply (rule_tac Q'="\<lambda>r s. silc_inv aag st s \<and> invs s \<and> pas_refined aag s
\<and> is_subject aag thread \<and> tcb_at thread s
\<and> cur_thread s = thread" in hoare_post_imp_R)
apply wp
apply ((clarsimp simp add: invs_valid_objs invs_sym_refs
| intro impI allI conjI
| rule cte_wp_valid_cap caps_of_state_cteD
| fastforce simp: aag_cap_auth_def cap_auth_conferred_def
cap_rights_to_auth_def valid_fault_def
)+)[1]
apply (wp delete_caller_cap_silc_inv | simp add: split_def cong: conj_cong)+
apply(wp | simp add: invs_valid_objs invs_mdb invs_sym_refs tcb_at_invs)+
done
lemma handle_interrupt_silc_inv:
"\<lbrace>silc_inv aag st\<rbrace> handle_interrupt irq \<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
unfolding handle_interrupt_def
apply (rule hoare_if)
apply(wp | wpc | simp add: handle_reserved_irq_def | wp_once hoare_drop_imps)+
done
lemma handle_vm_fault_silc_inv:
"\<lbrace>silc_inv aag st\<rbrace> handle_vm_fault thread vmfault_type
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
apply(case_tac vmfault_type)
apply(wp | simp)+
done
crunch silc_inv: handle_hypervisor_fault "silc_inv aag st"
lemma handle_event_silc_inv:
"\<lbrace> silc_inv aag st and einvs and simple_sched_action and
(\<lambda>s. ev \<noteq> Interrupt \<longrightarrow> ct_active s) and
pas_refined aag and (\<lambda>s. ct_active s \<longrightarrow> is_subject aag (cur_thread s)) and domain_sep_inv (pasMaySendIrqs aag) st'\<rbrace>
handle_event ev
\<lbrace> \<lambda>_. silc_inv aag st\<rbrace>"
apply(case_tac ev, simp_all)
apply(rule hoare_pre)
apply(wpc
| wp handle_send_silc_inv[where st'=st'] handle_call_silc_inv[where st'=st']
handle_recv_silc_inv handle_reply_silc_inv
handle_interrupt_silc_inv handle_vm_fault_silc_inv hy_inv
| simp add: invs_valid_objs invs_mdb invs_sym_refs)+
apply(rule_tac E="\<lambda>rv s. silc_inv aag st s \<and> invs s \<and> valid_fault rv \<and> is_subject aag thread" and R="Q" and Q=Q for Q in hoare_post_impErr)
apply(wp handle_vm_fault_silc_inv handle_hypervisor_fault_silc_inv | simp add: invs_valid_objs invs_mdb invs_sym_refs)+
done
crunch silc_inv[wp]: activate_thread "silc_inv aag st"
lemma intra_label_cap_cur_thread[simp]:
"intra_label_cap aag slot (s\<lparr>cur_thread := X\<rparr>) = intra_label_cap aag slot s"
apply(simp add: intra_label_cap_def)
done
lemma slots_holding_overlapping_caps_cur_thread[simp]:
"slots_holding_overlapping_caps cap (s\<lparr>cur_thread := X\<rparr>) = slots_holding_overlapping_caps cap s"
apply(simp add: slots_holding_overlapping_caps_def2 ctes_wp_at_def)
done
lemma silc_inv_cur_thread[simp]:
"silc_inv aag st (s\<lparr>cur_thread := X\<rparr>) = silc_inv aag st s"
apply(simp add: silc_inv_def silc_dom_equiv_def equiv_for_def)
done
crunch silc_inv[wp]: schedule "silc_inv aag st"
(wp: alternative_wp OR_choice_weak_wp select_wp crunch_wps ignore: set_scheduler_action ARM.clearExMonitor simp: crunch_simps ignore: set_scheduler_action ARM.clearExMonitor)
lemma call_kernel_silc_inv:
"\<lbrace> silc_inv aag st and einvs and simple_sched_action and
(\<lambda>s. ev \<noteq> Interrupt \<longrightarrow> ct_active s) and
pas_refined aag and is_subject aag \<circ> cur_thread and domain_sep_inv (pasMaySendIrqs aag) st'\<rbrace>
call_kernel ev
\<lbrace> \<lambda>_. silc_inv aag st\<rbrace>"
apply (simp add: call_kernel_def getActiveIRQ_def)
apply (wp handle_interrupt_silc_inv handle_event_silc_inv[where st'=st'] | simp)+
done
end
end
|
Formal statement is: lemma has_contour_integral_eqpath: "\<lbrakk>(f has_contour_integral y) p; f contour_integrable_on \<gamma>; contour_integral p f = contour_integral \<gamma> f\<rbrakk> \<Longrightarrow> (f has_contour_integral y) \<gamma>" Informal statement is: If $f$ has a contour integral along a path $p$ and $f$ is contour integrable along a path $\gamma$, and the contour integral of $f$ along $p$ is equal to the contour integral of $f$ along $\gamma$, then $f$ has a contour integral along $\gamma$. |
Formal statement is: lemma bounded_linearI': fixes f ::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector" assumes "\<And>x y. f (x + y) = f x + f y" and "\<And>c x. f (c *\<^sub>R x) = c *\<^sub>R f x" shows "bounded_linear f" Informal statement is: If $f$ is a linear map from a Euclidean space to a normed vector space, then $f$ is bounded. |
Formal statement is: proposition homotopic_loops_eq: "\<lbrakk>path p; path_image p \<subseteq> s; pathfinish p = pathstart p; \<And>t. t \<in> {0..1} \<Longrightarrow> p(t) = q(t)\<rbrakk> \<Longrightarrow> homotopic_loops s p q" Informal statement is: If two paths $p$ and $q$ have the same image and the same endpoints, then they are homotopic loops. |
(* Author: Tobias Nipkow *)
section \<open>2-3 Trees\<close>
theory Tree23
imports Main
begin
class height =
fixes height :: "'a \<Rightarrow> nat"
datatype 'a tree23 =
Leaf ("\<langle>\<rangle>") |
Node2 "'a tree23" 'a "'a tree23" ("\<langle>_, _, _\<rangle>") |
Node3 "'a tree23" 'a "'a tree23" 'a "'a tree23" ("\<langle>_, _, _, _, _\<rangle>")
fun inorder :: "'a tree23 \<Rightarrow> 'a list" where
"inorder Leaf = []" |
"inorder(Node2 l a r) = inorder l @ a # inorder r" |
"inorder(Node3 l a m b r) = inorder l @ a # inorder m @ b # inorder r"
instantiation tree23 :: (type)height
begin
fun height_tree23 :: "'a tree23 \<Rightarrow> nat" where
"height Leaf = 0" |
"height (Node2 l _ r) = Suc(max (height l) (height r))" |
"height (Node3 l _ m _ r) = Suc(max (height l) (max (height m) (height r)))"
instance ..
end
text \<open>Balanced:\<close>
fun complete :: "'a tree23 \<Rightarrow> bool" where
"complete Leaf = True" |
"complete (Node2 l _ r) = (complete l & complete r & height l = height r)" |
"complete (Node3 l _ m _ r) =
(complete l & complete m & complete r & height l = height m & height m = height r)"
lemma ht_sz_if_complete: "complete t \<Longrightarrow> 2 ^ height t \<le> size t + 1"
by (induction t) auto
end
|
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x : α
l : List α
h : ¬x ∈ l
⊢ ↑(formPerm l) x = x
[PROOFSTEP]
cases' l with y l
[GOAL]
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x : α
h : ¬x ∈ []
⊢ ↑(formPerm []) x = x
[PROOFSTEP]
simp
[GOAL]
case cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y : α
l : List α
h : ¬x ∈ y :: l
⊢ ↑(formPerm (y :: l)) x = x
[PROOFSTEP]
induction' l with z l IH generalizing x y
[GOAL]
case cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝¹ x✝ y✝ : α
l : List α
h✝ : ¬x✝ ∈ y✝ :: l
x y : α
h : ¬x ∈ [y]
⊢ ↑(formPerm [y]) x = x
[PROOFSTEP]
simp
[GOAL]
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ¬x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ¬x ∈ y :: l → ↑(formPerm (y :: l)) x = x
x y : α
h : ¬x ∈ y :: z :: l
⊢ ↑(formPerm (y :: z :: l)) x = x
[PROOFSTEP]
specialize IH x z (mt (mem_cons_of_mem y) h)
[GOAL]
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ¬x✝ ∈ y✝ :: l✝
z : α
l : List α
x y : α
h : ¬x ∈ y :: z :: l
IH : ↑(formPerm (z :: l)) x = x
⊢ ↑(formPerm (y :: z :: l)) x = x
[PROOFSTEP]
simp only [not_or, mem_cons] at h
[GOAL]
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ¬x✝ ∈ y✝ :: l✝
z : α
l : List α
x y : α
IH : ↑(formPerm (z :: l)) x = x
h : ¬x = y ∧ ¬x = z ∧ ¬x ∈ l
⊢ ↑(formPerm (y :: z :: l)) x = x
[PROOFSTEP]
simp [IH, swap_apply_of_ne_of_ne, h]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x : α
l : List α
h : x ∈ l
⊢ ↑(formPerm l) x ∈ l
[PROOFSTEP]
cases' l with y l
[GOAL]
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x : α
h : x ∈ []
⊢ ↑(formPerm []) x ∈ []
[PROOFSTEP]
simp at h
[GOAL]
case cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y : α
l : List α
h : x ∈ y :: l
⊢ ↑(formPerm (y :: l)) x ∈ y :: l
[PROOFSTEP]
induction' l with z l IH generalizing x y
[GOAL]
case cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝¹ x✝ y✝ : α
l : List α
h✝ : x✝ ∈ y✝ :: l
x y : α
h : x ∈ [y]
⊢ ↑(formPerm [y]) x ∈ [y]
[PROOFSTEP]
simpa using h
[GOAL]
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), x ∈ y :: l → ↑(formPerm (y :: l)) x ∈ y :: l
x y : α
h : x ∈ y :: z :: l
⊢ ↑(formPerm (y :: z :: l)) x ∈ y :: z :: l
[PROOFSTEP]
by_cases hx : x ∈ z :: l
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), x ∈ y :: l → ↑(formPerm (y :: l)) x ∈ y :: l
x y : α
h : x ∈ y :: z :: l
hx : x ∈ z :: l
⊢ ↑(formPerm (y :: z :: l)) x ∈ y :: z :: l
[PROOFSTEP]
rw [formPerm_cons_cons, mul_apply, swap_apply_def]
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), x ∈ y :: l → ↑(formPerm (y :: l)) x ∈ y :: l
x y : α
h : x ∈ y :: z :: l
hx : x ∈ z :: l
⊢ (if ↑(formPerm (z :: l)) x = y then z else if ↑(formPerm (z :: l)) x = z then y else ↑(formPerm (z :: l)) x) ∈
y :: z :: l
[PROOFSTEP]
split_ifs
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), x ∈ y :: l → ↑(formPerm (y :: l)) x ∈ y :: l
x y : α
h : x ∈ y :: z :: l
hx : x ∈ z :: l
h✝ : ↑(formPerm (z :: l)) x = y
⊢ z ∈ y :: z :: l
[PROOFSTEP]
simp [IH _ _ hx]
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝² : x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), x ∈ y :: l → ↑(formPerm (y :: l)) x ∈ y :: l
x y : α
h : x ∈ y :: z :: l
hx : x ∈ z :: l
h✝¹ : ¬↑(formPerm (z :: l)) x = y
h✝ : ↑(formPerm (z :: l)) x = z
⊢ y ∈ y :: z :: l
[PROOFSTEP]
simp
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝² : x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), x ∈ y :: l → ↑(formPerm (y :: l)) x ∈ y :: l
x y : α
h : x ∈ y :: z :: l
hx : x ∈ z :: l
h✝¹ : ¬↑(formPerm (z :: l)) x = y
h✝ : ¬↑(formPerm (z :: l)) x = z
⊢ ↑(formPerm (z :: l)) x ∈ y :: z :: l
[PROOFSTEP]
simpa [*] using IH _ _ hx
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), x ∈ y :: l → ↑(formPerm (y :: l)) x ∈ y :: l
x y : α
h : x ∈ y :: z :: l
hx : ¬x ∈ z :: l
⊢ ↑(formPerm (y :: z :: l)) x ∈ y :: z :: l
[PROOFSTEP]
replace h : x = y := Or.resolve_right (mem_cons.1 h) hx
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), x ∈ y :: l → ↑(formPerm (y :: l)) x ∈ y :: l
x y : α
hx : ¬x ∈ z :: l
h : x = y
⊢ ↑(formPerm (y :: z :: l)) x ∈ y :: z :: l
[PROOFSTEP]
simp [formPerm_apply_of_not_mem _ _ hx, ← h]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x : α
l : List α
h : ↑(formPerm l) x ∈ l
⊢ x ∈ l
[PROOFSTEP]
cases' l with y l
[GOAL]
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x : α
h : ↑(formPerm []) x ∈ []
⊢ x ∈ []
[PROOFSTEP]
simp at h
[GOAL]
case cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y : α
l : List α
h : ↑(formPerm (y :: l)) x ∈ y :: l
⊢ x ∈ y :: l
[PROOFSTEP]
induction' l with z l IH generalizing x y
[GOAL]
case cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝¹ x✝ y✝ : α
l : List α
h✝ : ↑(formPerm (y✝ :: l)) x✝ ∈ y✝ :: l
x y : α
h : ↑(formPerm [y]) x ∈ [y]
⊢ x ∈ [y]
[PROOFSTEP]
simpa using h
[GOAL]
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
h : ↑(formPerm (y :: z :: l)) x ∈ y :: z :: l
⊢ x ∈ y :: z :: l
[PROOFSTEP]
by_cases hx : (z :: l).formPerm x ∈ z :: l
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
h : ↑(formPerm (y :: z :: l)) x ∈ y :: z :: l
hx : ↑(formPerm (z :: l)) x ∈ z :: l
⊢ x ∈ y :: z :: l
[PROOFSTEP]
rw [List.formPerm_cons_cons, mul_apply, swap_apply_def] at h
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
h :
(if ↑(formPerm (z :: l)) x = y then z else if ↑(formPerm (z :: l)) x = z then y else ↑(formPerm (z :: l)) x) ∈
y :: z :: l
hx : ↑(formPerm (z :: l)) x ∈ z :: l
⊢ x ∈ y :: z :: l
[PROOFSTEP]
split_ifs at h
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x ∈ z :: l
h✝ : ↑(formPerm (z :: l)) x = y
h : z ∈ y :: z :: l
⊢ x ∈ y :: z :: l
[PROOFSTEP]
aesop
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝² : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x ∈ z :: l
h✝¹ : ¬↑(formPerm (z :: l)) x = y
h✝ : ↑(formPerm (z :: l)) x = z
h : y ∈ y :: z :: l
⊢ x ∈ y :: z :: l
[PROOFSTEP]
aesop
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝² : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x ∈ z :: l
h✝¹ : ¬↑(formPerm (z :: l)) x = y
h✝ : ¬↑(formPerm (z :: l)) x = z
h : ↑(formPerm (z :: l)) x ∈ y :: z :: l
⊢ x ∈ y :: z :: l
[PROOFSTEP]
aesop
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
h : ↑(formPerm (y :: z :: l)) x ∈ y :: z :: l
hx : ¬↑(formPerm (z :: l)) x ∈ z :: l
⊢ x ∈ y :: z :: l
[PROOFSTEP]
replace hx := (Function.Injective.eq_iff (Equiv.injective _)).mp (List.formPerm_apply_of_not_mem _ _ hx)
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
h : ↑(formPerm (y :: z :: l)) x ∈ y :: z :: l
hx : ↑(formPerm (z :: l)) x = x
⊢ x ∈ y :: z :: l
[PROOFSTEP]
simp only [List.formPerm_cons_cons, hx, Equiv.Perm.coe_mul, Function.comp_apply, List.mem_cons, swap_apply_def,
ite_eq_left_iff] at h
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h :
(if x = y then z else if x = z then y else x) = y ∨
(¬x = y → (if x = z then y else x) = z) ∨ (if x = y then z else if x = z then y else x) ∈ l
⊢ x ∈ y :: z :: l
[PROOFSTEP]
simp only [List.mem_cons]
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h :
(if x = y then z else if x = z then y else x) = y ∨
(¬x = y → (if x = z then y else x) = z) ∨ (if x = y then z else if x = z then y else x) ∈ l
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
rcases h with h | h | h
[GOAL]
case neg.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h : (if x = y then z else if x = z then y else x) = y
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
split_ifs at h with h1
[GOAL]
case neg.inr.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h : ¬x = y → (if x = z then y else x) = z
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
split_ifs at h with h1
[GOAL]
case neg.inr.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h : (if x = y then z else if x = z then y else x) ∈ l
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
split_ifs at h with h1
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : x = y
h : z = y
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
try {aesop
}
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : x = y
h : z = y
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
{aesop
}
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : x = y
h : z = y
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
aesop
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : x = z
h : y = y
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
try {aesop
}
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : x = z
h : y = y
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
{aesop
}
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : x = z
h : y = y
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
aesop
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : ¬x = z
h : x = y
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
try {aesop
}
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : ¬x = z
h : x = y
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
{aesop
}
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : ¬x = z
h : x = y
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
aesop
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : x = z
h : ¬x = y → y = z
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
try {aesop
}
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : x = z
h : ¬x = y → y = z
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
{aesop
}
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : x = z
h : ¬x = y → y = z
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
aesop
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = z
h : ¬x = y → x = z
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
try {aesop
}
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = z
h : ¬x = y → x = z
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
{aesop
}
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = z
h : ¬x = y → x = z
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
aesop
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : x = y
h : z ∈ l
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
try {aesop
}
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : x = y
h : z ∈ l
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
{aesop
}
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : x = y
h : z ∈ l
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
aesop
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : x = z
h : y ∈ l
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
try {aesop
}
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : x = z
h : y ∈ l
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
{aesop
}
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : x = z
h : y ∈ l
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
aesop
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : ¬x = z
h : x ∈ l
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
try {aesop
}
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : ¬x = z
h : x ∈ l
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
{aesop
}
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝¹ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = y
h✝ : ¬x = z
h : x ∈ l
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
aesop
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = z
h : ¬x = y → x = z
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
simp [h1, imp_false] at h
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝¹ : List α
x✝¹ x✝ y✝ : α
l✝ : List α
h✝ : ↑(formPerm (y✝ :: l✝)) x✝ ∈ y✝ :: l✝
z : α
l : List α
IH : ∀ (x y : α), ↑(formPerm (y :: l)) x ∈ y :: l → x ∈ y :: l
x y : α
hx : ↑(formPerm (z :: l)) x = x
h1 : ¬x = z
h : x = y
⊢ x = y ∨ x = z ∨ x ∈ l
[PROOFSTEP]
simp [h]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x y : α
xs : List α
⊢ ↑(formPerm (x :: (xs ++ [y]))) y = x
[PROOFSTEP]
induction' xs with z xs IH generalizing x y
[GOAL]
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝¹ x✝ y✝ x y : α
⊢ ↑(formPerm (x :: ([] ++ [y]))) y = x
[PROOFSTEP]
simp
[GOAL]
case cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝¹ x✝ y✝ z : α
xs : List α
IH : ∀ (x y : α), ↑(formPerm (x :: (xs ++ [y]))) y = x
x y : α
⊢ ↑(formPerm (x :: (z :: xs ++ [y]))) y = x
[PROOFSTEP]
simp [IH]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x : α
xs : List α
⊢ ↑(formPerm (x :: xs)) (getLast (x :: xs) (_ : x :: xs ≠ [])) = x
[PROOFSTEP]
induction' xs using List.reverseRecOn with xs y _ generalizing x
[GOAL]
case H0
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝¹ x✝ x : α
⊢ ↑(formPerm [x]) (getLast [x] (_ : [x] ≠ [])) = x
[PROOFSTEP]
simp
[GOAL]
case H1
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝¹ x✝ : α
xs : List α
y : α
a✝ : ∀ (x : α), ↑(formPerm (x :: xs)) (getLast (x :: xs) (_ : x :: xs ≠ [])) = x
x : α
⊢ ↑(formPerm (x :: (xs ++ [y]))) (getLast (x :: (xs ++ [y])) (_ : x :: (xs ++ [y]) ≠ [])) = x
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x : α
xs : List α
⊢ length xs < length (x :: xs)
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x : α
xs : List α
⊢ ↑(formPerm (x :: xs)) (nthLe (x :: xs) (length xs) (_ : length xs < Nat.succ (length xs))) = x
[PROOFSTEP]
rw [nthLe_cons_length, formPerm_apply_getLast]
[GOAL]
case h
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x : α
xs : List α
⊢ length xs = length xs
[PROOFSTEP]
rfl
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x y : α
xs : List α
h : Nodup (x :: y :: xs)
⊢ ↑(formPerm (x :: y :: xs)) x = y
[PROOFSTEP]
simp [formPerm_apply_of_not_mem _ _ h.not_mem]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
hl : 1 < length l
⊢ ↑(formPerm l) (nthLe l 0 (_ : 0 < length l)) = nthLe l 1 hl
[PROOFSTEP]
rcases l with (_ | ⟨x, _ | ⟨y, tl⟩⟩)
[GOAL]
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
h : Nodup []
hl : 1 < length []
⊢ ↑(formPerm []) (nthLe [] 0 (_ : 0 < length [])) = nthLe [] 1 hl
[PROOFSTEP]
simp at hl
[GOAL]
case cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x : α
h : Nodup [x]
hl : 1 < length [x]
⊢ ↑(formPerm [x]) (nthLe [x] 0 (_ : 0 < length [x])) = nthLe [x] 1 hl
[PROOFSTEP]
simp
[GOAL]
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x y : α
tl : List α
h : Nodup (x :: y :: tl)
hl : 1 < length (x :: y :: tl)
⊢ ↑(formPerm (x :: y :: tl)) (nthLe (x :: y :: tl) 0 (_ : 0 < length (x :: y :: tl))) = nthLe (x :: y :: tl) 1 hl
[PROOFSTEP]
simpa using formPerm_apply_head _ _ _ h
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x y : α
⊢ ↑(formPerm (y :: l)) x = y ↔ ↑(formPerm (y :: l)) x = ↑(formPerm (y :: l)) (getLast (y :: l) (_ : y :: l ≠ []))
[PROOFSTEP]
rw [formPerm_apply_getLast]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l l' : List α
⊢ {x | ↑(prod (zipWith swap l l')) x ≠ x} ≤ ↑(toFinset l ⊔ toFinset l')
[PROOFSTEP]
simp only [Set.sup_eq_union, Set.le_eq_subset]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l l' : List α
⊢ {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
[PROOFSTEP]
induction' l with y l hl generalizing l'
[GOAL]
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
l'✝ l' : List α
⊢ {x | ↑(prod (zipWith swap [] l')) x ≠ x} ⊆ ↑(toFinset [] ⊔ toFinset l')
[PROOFSTEP]
simp
[GOAL]
case cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l'✝ : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
l' : List α
⊢ {x | ↑(prod (zipWith swap (y :: l) l')) x ≠ x} ⊆ ↑(toFinset (y :: l) ⊔ toFinset l')
[PROOFSTEP]
cases' l' with z l'
[GOAL]
case cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l' : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
⊢ {x | ↑(prod (zipWith swap (y :: l) [])) x ≠ x} ⊆ ↑(toFinset (y :: l) ⊔ toFinset [])
[PROOFSTEP]
simp
[GOAL]
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l'✝ : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
z : α
l' : List α
⊢ {x | ↑(prod (zipWith swap (y :: l) (z :: l'))) x ≠ x} ⊆ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
intro x
[GOAL]
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
z : α
l' : List α
x : α
⊢ x ∈ {x | ↑(prod (zipWith swap (y :: l) (z :: l'))) x ≠ x} → x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
simp only [Set.union_subset_iff, mem_cons, zipWith_cons_cons, foldr, prod_cons, mul_apply]
[GOAL]
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
z : α
l' : List α
x : α
⊢ x ∈ {x | ↑(swap y z) (↑(prod (zipWith swap l l')) x) ≠ x} → x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
intro hx
[GOAL]
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
z : α
l' : List α
x : α
hx : x ∈ {x | ↑(swap y z) (↑(prod (zipWith swap l l')) x) ≠ x}
⊢ x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
by_cases h : x ∈ {x | (zipWith swap l l').prod x ≠ x}
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
z : α
l' : List α
x : α
hx : x ∈ {x | ↑(swap y z) (↑(prod (zipWith swap l l')) x) ≠ x}
h : x ∈ {x | ↑(prod (zipWith swap l l')) x ≠ x}
⊢ x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
specialize hl l' h
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
z : α
l' : List α
x : α
hx : x ∈ {x | ↑(swap y z) (↑(prod (zipWith swap l l')) x) ≠ x}
h : x ∈ {x | ↑(prod (zipWith swap l l')) x ≠ x}
hl : x ∈ ↑(toFinset l ⊔ toFinset l')
⊢ x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
simp only [ge_iff_le, Finset.le_eq_subset, Finset.sup_eq_union, Finset.coe_union, coe_toFinset, Set.mem_union,
Set.mem_setOf_eq] at hl
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
z : α
l' : List α
x : α
hx : x ∈ {x | ↑(swap y z) (↑(prod (zipWith swap l l')) x) ≠ x}
h : x ∈ {x | ↑(prod (zipWith swap l l')) x ≠ x}
hl : x ∈ l ∨ x ∈ l'
⊢ x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
refine' Or.elim hl (fun hm => _) fun hm => _
[GOAL]
case pos.refine'_1
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
z : α
l' : List α
x : α
hx : x ∈ {x | ↑(swap y z) (↑(prod (zipWith swap l l')) x) ≠ x}
h : x ∈ {x | ↑(prod (zipWith swap l l')) x ≠ x}
hl : x ∈ l ∨ x ∈ l'
hm : x ∈ l
⊢ x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
simp only [Finset.coe_insert, Set.mem_insert_iff, Finset.mem_coe, toFinset_cons, mem_toFinset] at hm ⊢
[GOAL]
case pos.refine'_1
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
z : α
l' : List α
x : α
hx : x ∈ {x | ↑(swap y z) (↑(prod (zipWith swap l l')) x) ≠ x}
h : x ∈ {x | ↑(prod (zipWith swap l l')) x ≠ x}
hl : x ∈ l ∨ x ∈ l'
hm : x ∈ l
⊢ x ∈ insert y (toFinset l) ⊔ insert z (toFinset l')
[PROOFSTEP]
simp [hm]
[GOAL]
case pos.refine'_2
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
z : α
l' : List α
x : α
hx : x ∈ {x | ↑(swap y z) (↑(prod (zipWith swap l l')) x) ≠ x}
h : x ∈ {x | ↑(prod (zipWith swap l l')) x ≠ x}
hl : x ∈ l ∨ x ∈ l'
hm : x ∈ l'
⊢ x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
simp only [Finset.coe_insert, Set.mem_insert_iff, Finset.mem_coe, toFinset_cons, mem_toFinset] at hm ⊢
[GOAL]
case pos.refine'_2
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
z : α
l' : List α
x : α
hx : x ∈ {x | ↑(swap y z) (↑(prod (zipWith swap l l')) x) ≠ x}
h : x ∈ {x | ↑(prod (zipWith swap l l')) x ≠ x}
hl : x ∈ l ∨ x ∈ l'
hm : x ∈ l'
⊢ x ∈ insert y (toFinset l) ⊔ insert z (toFinset l')
[PROOFSTEP]
simp [hm]
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
z : α
l' : List α
x : α
hx : x ∈ {x | ↑(swap y z) (↑(prod (zipWith swap l l')) x) ≠ x}
h : ¬x ∈ {x | ↑(prod (zipWith swap l l')) x ≠ x}
⊢ x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
simp only [not_not, Set.mem_setOf_eq] at h
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
z : α
l' : List α
x : α
hx : x ∈ {x | ↑(swap y z) (↑(prod (zipWith swap l l')) x) ≠ x}
h : ↑(prod (zipWith swap l l')) x = x
⊢ x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
simp only [h, Set.mem_setOf_eq] at hx
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
z : α
l' : List α
x : α
h : ↑(prod (zipWith swap l l')) x = x
hx : ↑(swap y z) x ≠ x
⊢ x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
rw [swap_apply_ne_self_iff] at hx
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
z : α
l' : List α
x : α
h : ↑(prod (zipWith swap l l')) x = x
hx : y ≠ z ∧ (x = y ∨ x = z)
⊢ x ∈ ↑(toFinset (y :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
rcases hx with ⟨hyz, rfl | rfl⟩
[GOAL]
case neg.intro.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
z : α
l' : List α
x : α
h : ↑(prod (zipWith swap l l')) x = x
hyz : x ≠ z
⊢ x ∈ ↑(toFinset (x :: l) ⊔ toFinset (z :: l'))
[PROOFSTEP]
simp
[GOAL]
case neg.intro.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l'✝ : List α
y : α
l : List α
hl : ∀ (l' : List α), {x | ↑(prod (zipWith swap l l')) x ≠ x} ⊆ ↑(toFinset l ⊔ toFinset l')
l' : List α
x : α
h : ↑(prod (zipWith swap l l')) x = x
hyz : y ≠ x
⊢ x ∈ ↑(toFinset (y :: l) ⊔ toFinset (x :: l'))
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
inst✝¹ : DecidableEq α
l✝ : List α
x : α
inst✝ : Fintype α
l l' : List α
⊢ support (prod (zipWith swap l l')) ≤ toFinset l ⊔ toFinset l'
[PROOFSTEP]
intro x hx
[GOAL]
α : Type u_1
β : Type u_2
inst✝¹ : DecidableEq α
l✝ : List α
x✝ : α
inst✝ : Fintype α
l l' : List α
x : α
hx : x ∈ support (prod (zipWith swap l l'))
⊢ x ∈ toFinset l ⊔ toFinset l'
[PROOFSTEP]
have hx' : x ∈ {x | (zipWith swap l l').prod x ≠ x} := by simpa using hx
[GOAL]
α : Type u_1
β : Type u_2
inst✝¹ : DecidableEq α
l✝ : List α
x✝ : α
inst✝ : Fintype α
l l' : List α
x : α
hx : x ∈ support (prod (zipWith swap l l'))
⊢ x ∈ {x | ↑(prod (zipWith swap l l')) x ≠ x}
[PROOFSTEP]
simpa using hx
[GOAL]
α : Type u_1
β : Type u_2
inst✝¹ : DecidableEq α
l✝ : List α
x✝ : α
inst✝ : Fintype α
l l' : List α
x : α
hx : x ∈ support (prod (zipWith swap l l'))
hx' : x ∈ {x | ↑(prod (zipWith swap l l')) x ≠ x}
⊢ x ∈ toFinset l ⊔ toFinset l'
[PROOFSTEP]
simpa using zipWith_swap_prod_support' _ _ hx'
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
⊢ {x | ↑(formPerm l) x ≠ x} ≤ ↑(toFinset l)
[PROOFSTEP]
refine' (zipWith_swap_prod_support' l l.tail).trans _
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
⊢ ↑(toFinset l ⊔ toFinset (tail l)) ≤ ↑(toFinset l)
[PROOFSTEP]
simpa [Finset.subset_iff] using tail_subset l
[GOAL]
α : Type u_1
β : Type u_2
inst✝¹ : DecidableEq α
l : List α
x : α
inst✝ : Fintype α
⊢ support (formPerm l) ≤ toFinset l
[PROOFSTEP]
intro x hx
[GOAL]
α : Type u_1
β : Type u_2
inst✝¹ : DecidableEq α
l : List α
x✝ : α
inst✝ : Fintype α
x : α
hx : x ∈ support (formPerm l)
⊢ x ∈ toFinset l
[PROOFSTEP]
have hx' : x ∈ {x | formPerm l x ≠ x} := by simpa using hx
[GOAL]
α : Type u_1
β : Type u_2
inst✝¹ : DecidableEq α
l : List α
x✝ : α
inst✝ : Fintype α
x : α
hx : x ∈ support (formPerm l)
⊢ x ∈ {x | ↑(formPerm l) x ≠ x}
[PROOFSTEP]
simpa using hx
[GOAL]
α : Type u_1
β : Type u_2
inst✝¹ : DecidableEq α
l : List α
x✝ : α
inst✝ : Fintype α
x : α
hx : x ∈ support (formPerm l)
hx' : x ∈ {x | ↑(formPerm l) x ≠ x}
⊢ x ∈ toFinset l
[PROOFSTEP]
simpa using support_formPerm_le' _ hx'
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
xs : List α
h : Nodup xs
n : ℕ
hn : n + 1 < length xs
⊢ ↑(formPerm xs) (nthLe xs n (_ : n < length xs)) = nthLe xs (n + 1) hn
[PROOFSTEP]
induction' n with n IH generalizing xs
[GOAL]
case zero
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
xs✝ : List α
h✝ : Nodup xs✝
n : ℕ
hn✝ : n + 1 < length xs✝
xs : List α
h : Nodup xs
hn : Nat.zero + 1 < length xs
⊢ ↑(formPerm xs) (nthLe xs Nat.zero (_ : Nat.zero < length xs)) = nthLe xs (Nat.zero + 1) hn
[PROOFSTEP]
simpa using formPerm_apply_nthLe_zero _ h _
[GOAL]
case succ
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
xs✝ : List α
h✝ : Nodup xs✝
n✝ : ℕ
hn✝ : n✝ + 1 < length xs✝
n : ℕ
IH :
∀ (xs : List α),
Nodup xs → ∀ (hn : n + 1 < length xs), ↑(formPerm xs) (nthLe xs n (_ : n < length xs)) = nthLe xs (n + 1) hn
xs : List α
h : Nodup xs
hn : Nat.succ n + 1 < length xs
⊢ ↑(formPerm xs) (nthLe xs (Nat.succ n) (_ : Nat.succ n < length xs)) = nthLe xs (Nat.succ n + 1) hn
[PROOFSTEP]
rcases xs with (_ | ⟨x, _ | ⟨y, l⟩⟩)
[GOAL]
case succ.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH :
∀ (xs : List α),
Nodup xs → ∀ (hn : n + 1 < length xs), ↑(formPerm xs) (nthLe xs n (_ : n < length xs)) = nthLe xs (n + 1) hn
h : Nodup []
hn : Nat.succ n + 1 < length []
⊢ ↑(formPerm []) (nthLe [] (Nat.succ n) (_ : Nat.succ n < length [])) = nthLe [] (Nat.succ n + 1) hn
[PROOFSTEP]
simp at hn
[GOAL]
case succ.cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH :
∀ (xs : List α),
Nodup xs → ∀ (hn : n + 1 < length xs), ↑(formPerm xs) (nthLe xs n (_ : n < length xs)) = nthLe xs (n + 1) hn
x : α
h : Nodup [x]
hn : Nat.succ n + 1 < length [x]
⊢ ↑(formPerm [x]) (nthLe [x] (Nat.succ n) (_ : Nat.succ n < length [x])) = nthLe [x] (Nat.succ n + 1) hn
[PROOFSTEP]
simp
[GOAL]
case succ.cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH :
∀ (xs : List α),
Nodup xs → ∀ (hn : n + 1 < length xs), ↑(formPerm xs) (nthLe xs n (_ : n < length xs)) = nthLe xs (n + 1) hn
x y : α
l : List α
h : Nodup (x :: y :: l)
hn : Nat.succ n + 1 < length (x :: y :: l)
⊢ ↑(formPerm (x :: y :: l)) (nthLe (x :: y :: l) (Nat.succ n) (_ : Nat.succ n < length (x :: y :: l))) =
nthLe (x :: y :: l) (Nat.succ n + 1) hn
[PROOFSTEP]
specialize IH (y :: l) h.of_cons _
[GOAL]
case succ.cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH :
∀ (xs : List α),
Nodup xs → ∀ (hn : n + 1 < length xs), ↑(formPerm xs) (nthLe xs n (_ : n < length xs)) = nthLe xs (n + 1) hn
x y : α
l : List α
h : Nodup (x :: y :: l)
hn : Nat.succ n + 1 < length (x :: y :: l)
⊢ n + 1 < length (y :: l)
[PROOFSTEP]
simpa [Nat.succ_lt_succ_iff] using hn
[GOAL]
case succ.cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH✝ :
∀ (xs : List α),
Nodup xs → ∀ (hn : n + 1 < length xs), ↑(formPerm xs) (nthLe xs n (_ : n < length xs)) = nthLe xs (n + 1) hn
x y : α
l : List α
h : Nodup (x :: y :: l)
hn : Nat.succ n + 1 < length (x :: y :: l)
IH :
↑(formPerm (y :: l)) (nthLe (y :: l) n (_ : n < length (y :: l))) =
nthLe (y :: l) (n + 1) (_ : n + 1 < length (y :: l))
⊢ ↑(formPerm (x :: y :: l)) (nthLe (x :: y :: l) (Nat.succ n) (_ : Nat.succ n < length (x :: y :: l))) =
nthLe (x :: y :: l) (Nat.succ n + 1) hn
[PROOFSTEP]
simp only [swap_apply_eq_iff, coe_mul, formPerm_cons_cons, Function.comp]
[GOAL]
case succ.cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH✝ :
∀ (xs : List α),
Nodup xs → ∀ (hn : n + 1 < length xs), ↑(formPerm xs) (nthLe xs n (_ : n < length xs)) = nthLe xs (n + 1) hn
x y : α
l : List α
h : Nodup (x :: y :: l)
hn : Nat.succ n + 1 < length (x :: y :: l)
IH :
↑(formPerm (y :: l)) (nthLe (y :: l) n (_ : n < length (y :: l))) =
nthLe (y :: l) (n + 1) (_ : n + 1 < length (y :: l))
⊢ ↑(formPerm (y :: l)) (nthLe (x :: y :: l) (Nat.succ n) (_ : Nat.succ n < length (x :: y :: l))) =
↑(swap x y) (nthLe (x :: y :: l) (Nat.succ n + 1) hn)
[PROOFSTEP]
simp only [nthLe, get_cons_succ] at *
[GOAL]
case succ.cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH✝ :
∀ (xs : List α),
Nodup xs →
∀ (hn : n + 1 < length xs),
↑(formPerm xs) (get xs { val := n, isLt := (_ : n < length xs) }) = get xs { val := n + 1, isLt := hn }
x y : α
l : List α
h : Nodup (x :: y :: l)
hn : Nat.succ n + 1 < length (x :: y :: l)
IH :
↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) =
get l { val := n, isLt := (_ : n < length l) }
⊢ ↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) =
↑(swap x y) (get l { val := n, isLt := (_ : n < length l) })
[PROOFSTEP]
rw [← IH, swap_apply_of_ne_of_ne]
[GOAL]
case succ.cons.cons.a
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH✝ :
∀ (xs : List α),
Nodup xs →
∀ (hn : n + 1 < length xs),
↑(formPerm xs) (get xs { val := n, isLt := (_ : n < length xs) }) = get xs { val := n + 1, isLt := hn }
x y : α
l : List α
h : Nodup (x :: y :: l)
hn : Nat.succ n + 1 < length (x :: y :: l)
IH :
↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) =
get l { val := n, isLt := (_ : n < length l) }
⊢ ↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) ≠ x
[PROOFSTEP]
intro hx
[GOAL]
case succ.cons.cons.a
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH✝ :
∀ (xs : List α),
Nodup xs →
∀ (hn : n + 1 < length xs),
↑(formPerm xs) (get xs { val := n, isLt := (_ : n < length xs) }) = get xs { val := n + 1, isLt := hn }
x y : α
l : List α
h : Nodup (x :: y :: l)
hn : Nat.succ n + 1 < length (x :: y :: l)
IH :
↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) =
get l { val := n, isLt := (_ : n < length l) }
hx : ↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) = x
⊢ False
[PROOFSTEP]
rw [← hx, IH] at h
[GOAL]
case succ.cons.cons.a
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH✝ :
∀ (xs : List α),
Nodup xs →
∀ (hn : n + 1 < length xs),
↑(formPerm xs) (get xs { val := n, isLt := (_ : n < length xs) }) = get xs { val := n + 1, isLt := hn }
x y : α
l : List α
hn : Nat.succ n + 1 < length (x :: y :: l)
h : Nodup (get l { val := n, isLt := (_ : n < length l) } :: y :: l)
IH :
↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) =
get l { val := n, isLt := (_ : n < length l) }
hx : ↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) = x
⊢ False
[PROOFSTEP]
simp [get_mem] at h
[GOAL]
case succ.cons.cons.a
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH✝ :
∀ (xs : List α),
Nodup xs →
∀ (hn : n + 1 < length xs),
↑(formPerm xs) (get xs { val := n, isLt := (_ : n < length xs) }) = get xs { val := n + 1, isLt := hn }
x y : α
l : List α
h : Nodup (x :: y :: l)
hn : Nat.succ n + 1 < length (x :: y :: l)
IH :
↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) =
get l { val := n, isLt := (_ : n < length l) }
⊢ ↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) ≠ y
[PROOFSTEP]
intro hx
[GOAL]
case succ.cons.cons.a
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH✝ :
∀ (xs : List α),
Nodup xs →
∀ (hn : n + 1 < length xs),
↑(formPerm xs) (get xs { val := n, isLt := (_ : n < length xs) }) = get xs { val := n + 1, isLt := hn }
x y : α
l : List α
h : Nodup (x :: y :: l)
hn : Nat.succ n + 1 < length (x :: y :: l)
IH :
↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) =
get l { val := n, isLt := (_ : n < length l) }
hx : ↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) = y
⊢ False
[PROOFSTEP]
rw [← hx, IH] at h
[GOAL]
case succ.cons.cons.a
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
xs : List α
h✝ : Nodup xs
n✝ : ℕ
hn✝ : n✝ + 1 < length xs
n : ℕ
IH✝ :
∀ (xs : List α),
Nodup xs →
∀ (hn : n + 1 < length xs),
↑(formPerm xs) (get xs { val := n, isLt := (_ : n < length xs) }) = get xs { val := n + 1, isLt := hn }
x y : α
l : List α
hn : Nat.succ n + 1 < length (x :: y :: l)
h : Nodup (x :: get l { val := n, isLt := (_ : n < length l) } :: l)
IH :
↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) =
get l { val := n, isLt := (_ : n < length l) }
hx : ↑(formPerm (y :: l)) (get (y :: l) { val := n, isLt := (_ : n < length (y :: l)) }) = y
⊢ False
[PROOFSTEP]
simp [get_mem] at h
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
xs : List α
h : Nodup xs
n : ℕ
hn : n < length xs
⊢ ↑(formPerm xs) (nthLe xs n hn) = nthLe xs ((n + 1) % length xs) (_ : (n + 1) % length xs < length xs)
[PROOFSTEP]
cases' xs with x xs
[GOAL]
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
n : ℕ
h : Nodup []
hn : n < length []
⊢ ↑(formPerm []) (nthLe [] n hn) = nthLe [] ((n + 1) % length []) (_ : (n + 1) % length [] < length [])
[PROOFSTEP]
simp at hn
[GOAL]
case cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
n : ℕ
x : α
xs : List α
h : Nodup (x :: xs)
hn : n < length (x :: xs)
⊢ ↑(formPerm (x :: xs)) (nthLe (x :: xs) n hn) =
nthLe (x :: xs) ((n + 1) % length (x :: xs)) (_ : (n + 1) % length (x :: xs) < length (x :: xs))
[PROOFSTEP]
have : n ≤ xs.length := by
refine' Nat.le_of_lt_succ _
simpa using hn
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
n : ℕ
x : α
xs : List α
h : Nodup (x :: xs)
hn : n < length (x :: xs)
⊢ n ≤ length xs
[PROOFSTEP]
refine' Nat.le_of_lt_succ _
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
n : ℕ
x : α
xs : List α
h : Nodup (x :: xs)
hn : n < length (x :: xs)
⊢ n < Nat.succ (length xs)
[PROOFSTEP]
simpa using hn
[GOAL]
case cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
n : ℕ
x : α
xs : List α
h : Nodup (x :: xs)
hn : n < length (x :: xs)
this : n ≤ length xs
⊢ ↑(formPerm (x :: xs)) (nthLe (x :: xs) n hn) =
nthLe (x :: xs) ((n + 1) % length (x :: xs)) (_ : (n + 1) % length (x :: xs) < length (x :: xs))
[PROOFSTEP]
rcases this.eq_or_lt with (rfl | hn')
[GOAL]
case cons.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x : α
xs : List α
h : Nodup (x :: xs)
hn : length xs < length (x :: xs)
this : length xs ≤ length xs
⊢ ↑(formPerm (x :: xs)) (nthLe (x :: xs) (length xs) hn) =
nthLe (x :: xs) ((length xs + 1) % length (x :: xs)) (_ : (length xs + 1) % length (x :: xs) < length (x :: xs))
[PROOFSTEP]
simp
[GOAL]
case cons.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ x : α
xs : List α
h : Nodup (x :: xs)
hn : length xs < length (x :: xs)
this : length xs ≤ length xs
⊢ x = nthLe (x :: xs) 0 (_ : 0 < length (x :: xs))
[PROOFSTEP]
simp [nthLe]
[GOAL]
case cons.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
n : ℕ
x : α
xs : List α
h : Nodup (x :: xs)
hn : n < length (x :: xs)
this : n ≤ length xs
hn' : n < length xs
⊢ ↑(formPerm (x :: xs)) (nthLe (x :: xs) n hn) =
nthLe (x :: xs) ((n + 1) % length (x :: xs)) (_ : (n + 1) % length (x :: xs) < length (x :: xs))
[PROOFSTEP]
rw [formPerm_apply_lt _ h _ (Nat.succ_lt_succ hn')]
[GOAL]
case cons.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
n : ℕ
x : α
xs : List α
h : Nodup (x :: xs)
hn : n < length (x :: xs)
this : n ≤ length xs
hn' : n < length xs
⊢ nthLe (x :: xs) (n + 1) (_ : Nat.succ n < Nat.succ (length xs)) =
nthLe (x :: xs) ((n + 1) % length (x :: xs)) (_ : (n + 1) % length (x :: xs) < length (x :: xs))
[PROOFSTEP]
congr
[GOAL]
case cons.inr.e_n
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
n : ℕ
x : α
xs : List α
h : Nodup (x :: xs)
hn : n < length (x :: xs)
this : n ≤ length xs
hn' : n < length xs
⊢ n + 1 = (n + 1) % length (x :: xs)
[PROOFSTEP]
rw [Nat.mod_eq_of_lt]
[GOAL]
case cons.inr.e_n
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
n : ℕ
x : α
xs : List α
h : Nodup (x :: xs)
hn : n < length (x :: xs)
this : n ≤ length xs
hn' : n < length xs
⊢ n + 1 < length (x :: xs)
[PROOFSTEP]
simpa [Nat.succ_eq_add_one]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
h' : ∀ (x : α), l ≠ [x]
⊢ {x | ↑(formPerm l) x ≠ x} = ↑(toFinset l)
[PROOFSTEP]
apply _root_.le_antisymm
[GOAL]
case a
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
h' : ∀ (x : α), l ≠ [x]
⊢ {x | ↑(formPerm l) x ≠ x} ≤ ↑(toFinset l)
[PROOFSTEP]
exact support_formPerm_le' l
[GOAL]
case a
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
h' : ∀ (x : α), l ≠ [x]
⊢ ↑(toFinset l) ≤ {x | ↑(formPerm l) x ≠ x}
[PROOFSTEP]
intro x hx
[GOAL]
case a
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
h' : ∀ (x : α), l ≠ [x]
x : α
hx : x ∈ ↑(toFinset l)
⊢ x ∈ {x | ↑(formPerm l) x ≠ x}
[PROOFSTEP]
simp only [Finset.mem_coe, mem_toFinset] at hx
[GOAL]
case a
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
h' : ∀ (x : α), l ≠ [x]
x : α
hx : x ∈ l
⊢ x ∈ {x | ↑(formPerm l) x ≠ x}
[PROOFSTEP]
obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx
[GOAL]
case a.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
h' : ∀ (x : α), l ≠ [x]
n : ℕ
hn : n < length l
hx : nthLe l n hn ∈ l
⊢ nthLe l n hn ∈ {x | ↑(formPerm l) x ≠ x}
[PROOFSTEP]
rw [Set.mem_setOf_eq, formPerm_apply_nthLe _ h]
[GOAL]
case a.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
h' : ∀ (x : α), l ≠ [x]
n : ℕ
hn : n < length l
hx : nthLe l n hn ∈ l
⊢ nthLe l ((n + 1) % length l) (_ : (n + 1) % length l < length l) ≠ nthLe l n hn
[PROOFSTEP]
intro H
[GOAL]
case a.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
h' : ∀ (x : α), l ≠ [x]
n : ℕ
hn : n < length l
hx : nthLe l n hn ∈ l
H : nthLe l ((n + 1) % length l) (_ : (n + 1) % length l < length l) = nthLe l n hn
⊢ False
[PROOFSTEP]
rw [nodup_iff_nthLe_inj] at h
[GOAL]
case a.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : ∀ (i j : ℕ) (h₁ : i < length l) (h₂ : j < length l), nthLe l i h₁ = nthLe l j h₂ → i = j
h' : ∀ (x : α), l ≠ [x]
n : ℕ
hn : n < length l
hx : nthLe l n hn ∈ l
H : nthLe l ((n + 1) % length l) (_ : (n + 1) % length l < length l) = nthLe l n hn
⊢ False
[PROOFSTEP]
specialize h _ _ _ _ H
[GOAL]
case a.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h' : ∀ (x : α), l ≠ [x]
n : ℕ
hn : n < length l
hx : nthLe l n hn ∈ l
H : nthLe l ((n + 1) % length l) (_ : (n + 1) % length l < length l) = nthLe l n hn
h : (n + 1) % length l = n
⊢ False
[PROOFSTEP]
cases' (Nat.succ_le_of_lt hn).eq_or_lt with hn' hn'
[GOAL]
case a.intro.intro.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h' : ∀ (x : α), l ≠ [x]
n : ℕ
hn : n < length l
hx : nthLe l n hn ∈ l
H : nthLe l ((n + 1) % length l) (_ : (n + 1) % length l < length l) = nthLe l n hn
h : (n + 1) % length l = n
hn' : Nat.succ n = length l
⊢ False
[PROOFSTEP]
simp only [← hn', Nat.mod_self] at h
[GOAL]
case a.intro.intro.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h' : ∀ (x : α), l ≠ [x]
n : ℕ
hn : n < length l
hx : nthLe l n hn ∈ l
H : nthLe l ((n + 1) % length l) (_ : (n + 1) % length l < length l) = nthLe l n hn
hn' : Nat.succ n = length l
h : 0 = n
⊢ False
[PROOFSTEP]
refine' not_exists.mpr h' _
[GOAL]
case a.intro.intro.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h' : ∀ (x : α), l ≠ [x]
n : ℕ
hn : n < length l
hx : nthLe l n hn ∈ l
H : nthLe l ((n + 1) % length l) (_ : (n + 1) % length l < length l) = nthLe l n hn
hn' : Nat.succ n = length l
h : 0 = n
⊢ ∃ x, l = [x]
[PROOFSTEP]
rw [← length_eq_one]
[GOAL]
case a.intro.intro.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h' : ∀ (x : α), l ≠ [x]
n : ℕ
hn : n < length l
hx : nthLe l n hn ∈ l
H : nthLe l ((n + 1) % length l) (_ : (n + 1) % length l < length l) = nthLe l n hn
hn' : Nat.succ n = length l
h : 0 = n
⊢ length l = 1
[PROOFSTEP]
simpa [← h, eq_comm] using hn'
[GOAL]
case a.intro.intro.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h' : ∀ (x : α), l ≠ [x]
n : ℕ
hn : n < length l
hx : nthLe l n hn ∈ l
H : nthLe l ((n + 1) % length l) (_ : (n + 1) % length l < length l) = nthLe l n hn
h : (n + 1) % length l = n
hn' : Nat.succ n < length l
⊢ False
[PROOFSTEP]
simp [Nat.mod_eq_of_lt hn'] at h
[GOAL]
α : Type u_1
β : Type u_2
inst✝¹ : DecidableEq α
l✝ : List α
x : α
inst✝ : Fintype α
l : List α
h : Nodup l
h' : ∀ (x : α), l ≠ [x]
⊢ support (formPerm l) = toFinset l
[PROOFSTEP]
rw [← Finset.coe_inj]
[GOAL]
α : Type u_1
β : Type u_2
inst✝¹ : DecidableEq α
l✝ : List α
x : α
inst✝ : Fintype α
l : List α
h : Nodup l
h' : ∀ (x : α), l ≠ [x]
⊢ ↑(support (formPerm l)) = ↑(toFinset l)
[PROOFSTEP]
convert support_formPerm_of_nodup' _ h h'
[GOAL]
case h.e'_2
α : Type u_1
β : Type u_2
inst✝¹ : DecidableEq α
l✝ : List α
x : α
inst✝ : Fintype α
l : List α
h : Nodup l
h' : ∀ (x : α), l ≠ [x]
⊢ ↑(support (formPerm l)) = {x | ↑(formPerm l) x ≠ x}
[PROOFSTEP]
simp [Set.ext_iff]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
⊢ formPerm (rotate l 1) = formPerm l
[PROOFSTEP]
have h' : Nodup (l.rotate 1) := by simpa using h
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
⊢ Nodup (rotate l 1)
[PROOFSTEP]
simpa using h
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
h' : Nodup (rotate l 1)
⊢ formPerm (rotate l 1) = formPerm l
[PROOFSTEP]
ext x
[GOAL]
case H
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
h' : Nodup (rotate l 1)
x : α
⊢ ↑(formPerm (rotate l 1)) x = ↑(formPerm l) x
[PROOFSTEP]
by_cases hx : x ∈ l.rotate 1
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
h' : Nodup (rotate l 1)
x : α
hx : x ∈ rotate l 1
⊢ ↑(formPerm (rotate l 1)) x = ↑(formPerm l) x
[PROOFSTEP]
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
[GOAL]
case pos.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
h' : Nodup (rotate l 1)
k : ℕ
hk : k < length (rotate l 1)
hx : nthLe (rotate l 1) k hk ∈ rotate l 1
⊢ ↑(formPerm (rotate l 1)) (nthLe (rotate l 1) k hk) = ↑(formPerm l) (nthLe (rotate l 1) k hk)
[PROOFSTEP]
rw [formPerm_apply_nthLe _ h', nthLe_rotate l, nthLe_rotate l, formPerm_apply_nthLe _ h]
[GOAL]
case pos.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
h' : Nodup (rotate l 1)
k : ℕ
hk : k < length (rotate l 1)
hx : nthLe (rotate l 1) k hk ∈ rotate l 1
⊢ nthLe l (((k + 1) % length (rotate l 1) + 1) % length l)
(_ : ((k + 1) % length (rotate l 1) + 1) % length l < length l) =
nthLe l (((k + 1) % length l + 1) % length l) (_ : ((k + 1) % length l + 1) % length l < length l)
[PROOFSTEP]
simp
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
h' : Nodup (rotate l 1)
x : α
hx : ¬x ∈ rotate l 1
⊢ ↑(formPerm (rotate l 1)) x = ↑(formPerm l) x
[PROOFSTEP]
rw [formPerm_apply_of_not_mem _ _ hx, formPerm_apply_of_not_mem]
[GOAL]
case neg.h
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
h' : Nodup (rotate l 1)
x : α
hx : ¬x ∈ rotate l 1
⊢ ¬x ∈ l
[PROOFSTEP]
simpa using hx
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
n : ℕ
⊢ formPerm (rotate l n) = formPerm l
[PROOFSTEP]
induction' n with n hn
[GOAL]
case zero
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
⊢ formPerm (rotate l Nat.zero) = formPerm l
[PROOFSTEP]
simp
[GOAL]
case succ
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
n : ℕ
hn : formPerm (rotate l n) = formPerm l
⊢ formPerm (rotate l (Nat.succ n)) = formPerm l
[PROOFSTEP]
rw [Nat.succ_eq_add_one, ← rotate_rotate, formPerm_rotate_one, hn]
[GOAL]
case succ.h
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
n : ℕ
hn : formPerm (rotate l n) = formPerm l
⊢ Nodup (rotate l n)
[PROOFSTEP]
rwa [IsRotated.nodup_iff]
[GOAL]
case succ.h
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
n : ℕ
hn : formPerm (rotate l n) = formPerm l
⊢ rotate l n ~r l
[PROOFSTEP]
exact IsRotated.forall l n
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l l' : List α
hd : Nodup l
h : l ~r l'
⊢ formPerm l = formPerm l'
[PROOFSTEP]
obtain ⟨n, rfl⟩ := h
[GOAL]
case intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
hd : Nodup l
n : ℕ
⊢ formPerm l = formPerm (rotate l n)
[PROOFSTEP]
exact (formPerm_rotate l hd n).symm
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
⊢ formPerm (reverse l) = (formPerm l)⁻¹
[PROOFSTEP]
rw [eq_comm, inv_eq_iff_mul_eq_one]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
⊢ formPerm l * formPerm (reverse l) = 1
[PROOFSTEP]
ext x
[GOAL]
case H
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
x : α
⊢ ↑(formPerm l * formPerm (reverse l)) x = ↑1 x
[PROOFSTEP]
rw [mul_apply, one_apply]
[GOAL]
case H
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
x : α
⊢ ↑(formPerm l) (↑(formPerm (reverse l)) x) = x
[PROOFSTEP]
cases' Classical.em (x ∈ l) with hx hx
[GOAL]
case H.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
x : α
hx : x ∈ l
⊢ ↑(formPerm l) (↑(formPerm (reverse l)) x) = x
[PROOFSTEP]
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem (mem_reverse.mpr hx)
[GOAL]
case H.inl.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
⊢ ↑(formPerm l) (↑(formPerm (reverse l)) (nthLe (reverse l) k hk)) = nthLe (reverse l) k hk
[PROOFSTEP]
have h1 : l.length - 1 - k < l.length := by
rw [Nat.sub_sub, add_comm]
exact Nat.sub_lt_self (Nat.succ_pos _) (Nat.succ_le_of_lt (by simpa using hk))
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
⊢ length l - 1 - k < length l
[PROOFSTEP]
rw [Nat.sub_sub, add_comm]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
⊢ length l - (k + 1) < length l
[PROOFSTEP]
exact Nat.sub_lt_self (Nat.succ_pos _) (Nat.succ_le_of_lt (by simpa using hk))
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
⊢ k < length l
[PROOFSTEP]
simpa using hk
[GOAL]
case H.inl.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
h1 : length l - 1 - k < length l
⊢ ↑(formPerm l) (↑(formPerm (reverse l)) (nthLe (reverse l) k hk)) = nthLe (reverse l) k hk
[PROOFSTEP]
have h2 : length l - 1 - (k + 1) % length (reverse l) < length l := by rw [Nat.sub_sub, length_reverse];
exact
Nat.sub_lt_self (by rw [add_comm]; exact Nat.succ_pos _)
(by rw [add_comm]; exact Nat.succ_le_of_lt (Nat.mod_lt _ (length_pos_of_mem hx)))
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
h1 : length l - 1 - k < length l
⊢ length l - 1 - (k + 1) % length (reverse l) < length l
[PROOFSTEP]
rw [Nat.sub_sub, length_reverse]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
h1 : length l - 1 - k < length l
⊢ length l - (1 + (k + 1) % length l) < length l
[PROOFSTEP]
exact
Nat.sub_lt_self (by rw [add_comm]; exact Nat.succ_pos _)
(by rw [add_comm]; exact Nat.succ_le_of_lt (Nat.mod_lt _ (length_pos_of_mem hx)))
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
h1 : length l - 1 - k < length l
⊢ 0 < 1 + (k + 1) % length l
[PROOFSTEP]
rw [add_comm]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
h1 : length l - 1 - k < length l
⊢ 0 < (k + 1) % length l + 1
[PROOFSTEP]
exact Nat.succ_pos _
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
h1 : length l - 1 - k < length l
⊢ 1 + (k + 1) % length l ≤ length l
[PROOFSTEP]
rw [add_comm]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
h1 : length l - 1 - k < length l
⊢ (k + 1) % length l + 1 ≤ length l
[PROOFSTEP]
exact Nat.succ_le_of_lt (Nat.mod_lt _ (length_pos_of_mem hx))
[GOAL]
case H.inl.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
h1 : length l - 1 - k < length l
h2 : length l - 1 - (k + 1) % length (reverse l) < length l
⊢ ↑(formPerm l) (↑(formPerm (reverse l)) (nthLe (reverse l) k hk)) = nthLe (reverse l) k hk
[PROOFSTEP]
rw [formPerm_apply_nthLe l.reverse (nodup_reverse.mpr h), nthLe_reverse' _ _ _ h1, nthLe_reverse' _ _ _ h2,
formPerm_apply_nthLe _ h]
[GOAL]
case H.inl.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
h1 : length l - 1 - k < length l
h2 : length l - 1 - (k + 1) % length (reverse l) < length l
⊢ nthLe l ((length l - 1 - (k + 1) % length (reverse l) + 1) % length l)
(_ : (length l - 1 - (k + 1) % length (reverse l) + 1) % length l < length l) =
nthLe l (length l - 1 - k) h1
[PROOFSTEP]
congr
[GOAL]
case H.inl.intro.intro.e_n
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length (reverse l)
hx : nthLe (reverse l) k hk ∈ l
h1 : length l - 1 - k < length l
h2 : length l - 1 - (k + 1) % length (reverse l) < length l
⊢ (length l - 1 - (k + 1) % length (reverse l) + 1) % length l = length l - 1 - k
[PROOFSTEP]
rw [length_reverse] at *
[GOAL]
case H.inl.intro.intro.e_n
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk✝ : k < length (reverse l)
hk : k < length l
hx : nthLe (reverse l) k hk✝ ∈ l
h1 : length l - 1 - k < length l
h2 : length l - 1 - (k + 1) % length l < length l
⊢ (length l - 1 - (k + 1) % length l + 1) % length l = length l - 1 - k
[PROOFSTEP]
cases' lt_or_eq_of_le (Nat.succ_le_of_lt hk) with h h
[GOAL]
case H.inl.intro.intro.e_n.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h✝ : Nodup l
k : ℕ
hk✝ : k < length (reverse l)
hk : k < length l
hx : nthLe (reverse l) k hk✝ ∈ l
h1 : length l - 1 - k < length l
h2 : length l - 1 - (k + 1) % length l < length l
h : Nat.succ k < length l
⊢ (length l - 1 - (k + 1) % length l + 1) % length l = length l - 1 - k
[PROOFSTEP]
rw [Nat.mod_eq_of_lt h, ← Nat.sub_add_comm, Nat.succ_sub_succ_eq_sub, Nat.mod_eq_of_lt h1]
[GOAL]
case H.inl.intro.intro.e_n.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h✝ : Nodup l
k : ℕ
hk✝ : k < length (reverse l)
hk : k < length l
hx : nthLe (reverse l) k hk✝ ∈ l
h1 : length l - 1 - k < length l
h2 : length l - 1 - (k + 1) % length l < length l
h : Nat.succ k < length l
⊢ Nat.succ k ≤ length l - 1
[PROOFSTEP]
exact (Nat.le_sub_iff_add_le (length_pos_of_mem hx)).2 (Nat.succ_le_of_lt h)
[GOAL]
case H.inl.intro.intro.e_n.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h✝ : Nodup l
k : ℕ
hk✝ : k < length (reverse l)
hk : k < length l
hx : nthLe (reverse l) k hk✝ ∈ l
h1 : length l - 1 - k < length l
h2 : length l - 1 - (k + 1) % length l < length l
h : Nat.succ k = length l
⊢ (length l - 1 - (k + 1) % length l + 1) % length l = length l - 1 - k
[PROOFSTEP]
rw [← h]
[GOAL]
case H.inl.intro.intro.e_n.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h✝ : Nodup l
k : ℕ
hk✝ : k < length (reverse l)
hk : k < length l
hx : nthLe (reverse l) k hk✝ ∈ l
h1 : length l - 1 - k < length l
h2 : length l - 1 - (k + 1) % length l < length l
h : Nat.succ k = length l
⊢ (Nat.succ k - 1 - (k + 1) % Nat.succ k + 1) % Nat.succ k = Nat.succ k - 1 - k
[PROOFSTEP]
simp
[GOAL]
case H.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
x : α
hx : ¬x ∈ l
⊢ ↑(formPerm l) (↑(formPerm (reverse l)) x) = x
[PROOFSTEP]
rw [formPerm_apply_of_not_mem x l.reverse, formPerm_apply_of_not_mem _ _ hx]
[GOAL]
case H.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
h : Nodup l
x : α
hx : ¬x ∈ l
⊢ ¬x ∈ reverse l
[PROOFSTEP]
simpa using hx
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
n k : ℕ
hk : k < length l
⊢ ↑(formPerm l ^ n) (nthLe l k hk) = nthLe l ((k + n) % length l) (_ : (k + n) % length l < length l)
[PROOFSTEP]
induction' n with n hn
[GOAL]
case zero
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
⊢ ↑(formPerm l ^ Nat.zero) (nthLe l k hk) =
nthLe l ((k + Nat.zero) % length l) (_ : (k + Nat.zero) % length l < length l)
[PROOFSTEP]
simp [Nat.mod_eq_of_lt hk]
[GOAL]
case succ
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l : List α
h : Nodup l
k : ℕ
hk : k < length l
n : ℕ
hn : ↑(formPerm l ^ n) (nthLe l k hk) = nthLe l ((k + n) % length l) (_ : (k + n) % length l < length l)
⊢ ↑(formPerm l ^ Nat.succ n) (nthLe l k hk) =
nthLe l ((k + Nat.succ n) % length l) (_ : (k + Nat.succ n) % length l < length l)
[PROOFSTEP]
simp [pow_succ, mul_apply, hn, formPerm_apply_nthLe _ h, Nat.succ_eq_add_one, ← Nat.add_assoc]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x : α
l : List α
h : Nodup (x :: l)
n : ℕ
⊢ ↑(formPerm (x :: l) ^ n) x = nthLe (x :: l) (n % length (x :: l)) (_ : n % length (x :: l) < length (x :: l))
[PROOFSTEP]
convert formPerm_pow_apply_nthLe _ h n 0 (Nat.succ_pos _)
[GOAL]
case h.e'_3.h.e'_3.h.e'_5
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x : α
l : List α
h : Nodup (x :: l)
n : ℕ
⊢ n = 0 + n
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
⊢ formPerm (x :: y :: l) = formPerm (x' :: y' :: l') ↔ (x :: y :: l) ~r (x' :: y' :: l')
[PROOFSTEP]
refine' ⟨fun h => _, fun hr => formPerm_eq_of_isRotated hd hr⟩
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : formPerm (x :: y :: l) = formPerm (x' :: y' :: l')
⊢ (x :: y :: l) ~r (x' :: y' :: l')
[PROOFSTEP]
rw [Equiv.Perm.ext_iff] at h
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
⊢ (x :: y :: l) ~r (x' :: y' :: l')
[PROOFSTEP]
have hx : x' ∈ x :: y :: l :=
by
have : x' ∈ {z | formPerm (x :: y :: l) z ≠ z} :=
by
rw [Set.mem_setOf_eq, h x', formPerm_apply_head _ _ _ hd']
simp only [mem_cons, nodup_cons] at hd'
push_neg at hd'
exact hd'.left.left.symm
simpa using support_formPerm_le' _ this
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
⊢ x' ∈ x :: y :: l
[PROOFSTEP]
have : x' ∈ {z | formPerm (x :: y :: l) z ≠ z} :=
by
rw [Set.mem_setOf_eq, h x', formPerm_apply_head _ _ _ hd']
simp only [mem_cons, nodup_cons] at hd'
push_neg at hd'
exact hd'.left.left.symm
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
⊢ x' ∈ {z | ↑(formPerm (x :: y :: l)) z ≠ z}
[PROOFSTEP]
rw [Set.mem_setOf_eq, h x', formPerm_apply_head _ _ _ hd']
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
⊢ y' ≠ x'
[PROOFSTEP]
simp only [mem_cons, nodup_cons] at hd'
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hd' : ¬(x' = y' ∨ x' ∈ l') ∧ ¬y' ∈ l' ∧ Nodup l'
⊢ y' ≠ x'
[PROOFSTEP]
push_neg at hd'
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hd' : (x' ≠ y' ∧ ¬x' ∈ l') ∧ ¬y' ∈ l' ∧ Nodup l'
⊢ y' ≠ x'
[PROOFSTEP]
exact hd'.left.left.symm
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
this : x' ∈ {z | ↑(formPerm (x :: y :: l)) z ≠ z}
⊢ x' ∈ x :: y :: l
[PROOFSTEP]
simpa using support_formPerm_le' _ this
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
⊢ (x :: y :: l) ~r (x' :: y' :: l')
[PROOFSTEP]
obtain ⟨n, hn, hx'⟩ := nthLe_of_mem hx
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
⊢ (x :: y :: l) ~r (x' :: y' :: l')
[PROOFSTEP]
have hl : (x :: y :: l).length = (x' :: y' :: l').length :=
by
rw [← dedup_eq_self.mpr hd, ← dedup_eq_self.mpr hd', ← card_toFinset, ← card_toFinset]
refine' congr_arg Finset.card _
rw [← Finset.coe_inj, ← support_formPerm_of_nodup' _ hd (by simp), ← support_formPerm_of_nodup' _ hd' (by simp)]
simp only [h]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
⊢ length (x :: y :: l) = length (x' :: y' :: l')
[PROOFSTEP]
rw [← dedup_eq_self.mpr hd, ← dedup_eq_self.mpr hd', ← card_toFinset, ← card_toFinset]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
⊢ Finset.card (toFinset (x :: y :: l)) = Finset.card (toFinset (x' :: y' :: l'))
[PROOFSTEP]
refine' congr_arg Finset.card _
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
⊢ toFinset (x :: y :: l) = toFinset (x' :: y' :: l')
[PROOFSTEP]
rw [← Finset.coe_inj, ← support_formPerm_of_nodup' _ hd (by simp), ← support_formPerm_of_nodup' _ hd' (by simp)]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
⊢ ∀ (x_1 : α), x :: y :: l ≠ [x_1]
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
⊢ ∀ (x : α), x' :: y' :: l' ≠ [x]
[PROOFSTEP]
simp
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
⊢ {x_1 | ↑(formPerm (x :: y :: l)) x_1 ≠ x_1} = {x | ↑(formPerm (x' :: y' :: l')) x ≠ x}
[PROOFSTEP]
simp only [h]
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
⊢ (x :: y :: l) ~r (x' :: y' :: l')
[PROOFSTEP]
use n
[GOAL]
case h
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
⊢ rotate (x :: y :: l) n = x' :: y' :: l'
[PROOFSTEP]
apply List.ext_nthLe
[GOAL]
case h.hl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
⊢ length (rotate (x :: y :: l) n) = length (x' :: y' :: l')
[PROOFSTEP]
rw [length_rotate, hl]
[GOAL]
case h.h
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
⊢ ∀ (n_1 : ℕ) (h₁ : n_1 < length (rotate (x :: y :: l) n)) (h₂ : n_1 < length (x' :: y' :: l')),
nthLe (rotate (x :: y :: l) n) n_1 h₁ = nthLe (x' :: y' :: l') n_1 h₂
[PROOFSTEP]
intro k hk hk'
[GOAL]
case h.h
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k : ℕ
hk : k < length (rotate (x :: y :: l) n)
hk' : k < length (x' :: y' :: l')
⊢ nthLe (rotate (x :: y :: l) n) k hk = nthLe (x' :: y' :: l') k hk'
[PROOFSTEP]
rw [nthLe_rotate]
[GOAL]
case h.h
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k : ℕ
hk : k < length (rotate (x :: y :: l) n)
hk' : k < length (x' :: y' :: l')
⊢ nthLe (x :: y :: l) ((k + n) % length (x :: y :: l)) (_ : (k + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') k hk'
[PROOFSTEP]
induction' k with k IH
[GOAL]
case h.h.zero
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k : ℕ
hk✝ : k < length (rotate (x :: y :: l) n)
hk'✝ : k < length (x' :: y' :: l')
hk : Nat.zero < length (rotate (x :: y :: l) n)
hk' : Nat.zero < length (x' :: y' :: l')
⊢ nthLe (x :: y :: l) ((Nat.zero + n) % length (x :: y :: l))
(_ : (Nat.zero + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') Nat.zero hk'
[PROOFSTEP]
refine' Eq.trans _ hx'
[GOAL]
case h.h.zero
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k : ℕ
hk✝ : k < length (rotate (x :: y :: l) n)
hk'✝ : k < length (x' :: y' :: l')
hk : Nat.zero < length (rotate (x :: y :: l) n)
hk' : Nat.zero < length (x' :: y' :: l')
⊢ nthLe (x :: y :: l) ((Nat.zero + n) % length (x :: y :: l))
(_ : (Nat.zero + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x :: y :: l) n hn
[PROOFSTEP]
congr
[GOAL]
case h.h.zero.e_n
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k : ℕ
hk✝ : k < length (rotate (x :: y :: l) n)
hk'✝ : k < length (x' :: y' :: l')
hk : Nat.zero < length (rotate (x :: y :: l) n)
hk' : Nat.zero < length (x' :: y' :: l')
⊢ (Nat.zero + n) % length (x :: y :: l) = n
[PROOFSTEP]
simpa using hn
[GOAL]
case h.h.succ
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k✝ : ℕ
hk✝ : k✝ < length (rotate (x :: y :: l) n)
hk'✝ : k✝ < length (x' :: y' :: l')
k : ℕ
IH :
∀ (hk : k < length (rotate (x :: y :: l) n)) (hk' : k < length (x' :: y' :: l')),
nthLe (x :: y :: l) ((k + n) % length (x :: y :: l)) (_ : (k + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') k hk'
hk : Nat.succ k < length (rotate (x :: y :: l) n)
hk' : Nat.succ k < length (x' :: y' :: l')
⊢ nthLe (x :: y :: l) ((Nat.succ k + n) % length (x :: y :: l))
(_ : (Nat.succ k + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') (Nat.succ k) hk'
[PROOFSTEP]
have : k.succ = (k + 1) % (x' :: y' :: l').length := by rw [← Nat.succ_eq_add_one, Nat.mod_eq_of_lt hk']
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k✝ : ℕ
hk✝ : k✝ < length (rotate (x :: y :: l) n)
hk'✝ : k✝ < length (x' :: y' :: l')
k : ℕ
IH :
∀ (hk : k < length (rotate (x :: y :: l) n)) (hk' : k < length (x' :: y' :: l')),
nthLe (x :: y :: l) ((k + n) % length (x :: y :: l)) (_ : (k + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') k hk'
hk : Nat.succ k < length (rotate (x :: y :: l) n)
hk' : Nat.succ k < length (x' :: y' :: l')
⊢ Nat.succ k = (k + 1) % length (x' :: y' :: l')
[PROOFSTEP]
rw [← Nat.succ_eq_add_one, Nat.mod_eq_of_lt hk']
[GOAL]
case h.h.succ
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k✝ : ℕ
hk✝ : k✝ < length (rotate (x :: y :: l) n)
hk'✝ : k✝ < length (x' :: y' :: l')
k : ℕ
IH :
∀ (hk : k < length (rotate (x :: y :: l) n)) (hk' : k < length (x' :: y' :: l')),
nthLe (x :: y :: l) ((k + n) % length (x :: y :: l)) (_ : (k + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') k hk'
hk : Nat.succ k < length (rotate (x :: y :: l) n)
hk' : Nat.succ k < length (x' :: y' :: l')
this : Nat.succ k = (k + 1) % length (x' :: y' :: l')
⊢ nthLe (x :: y :: l) ((Nat.succ k + n) % length (x :: y :: l))
(_ : (Nat.succ k + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') (Nat.succ k) hk'
[PROOFSTEP]
simp_rw [this]
[GOAL]
case h.h.succ
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k✝ : ℕ
hk✝ : k✝ < length (rotate (x :: y :: l) n)
hk'✝ : k✝ < length (x' :: y' :: l')
k : ℕ
IH :
∀ (hk : k < length (rotate (x :: y :: l) n)) (hk' : k < length (x' :: y' :: l')),
nthLe (x :: y :: l) ((k + n) % length (x :: y :: l)) (_ : (k + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') k hk'
hk : Nat.succ k < length (rotate (x :: y :: l) n)
hk' : Nat.succ k < length (x' :: y' :: l')
this : Nat.succ k = (k + 1) % length (x' :: y' :: l')
⊢ nthLe (x :: y :: l) (((k + 1) % length (x' :: y' :: l') + n) % length (x :: y :: l))
(_ : ((k + 1) % length (x' :: y' :: l') + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') ((k + 1) % length (x' :: y' :: l'))
(_ : (k + 1) % length (x' :: y' :: l') < length (x' :: y' :: l'))
[PROOFSTEP]
rw [← formPerm_apply_nthLe _ hd' k (k.lt_succ_self.trans hk'), ← IH (k.lt_succ_self.trans hk), ← h,
formPerm_apply_nthLe _ hd]
[GOAL]
case h.h.succ
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k✝ : ℕ
hk✝ : k✝ < length (rotate (x :: y :: l) n)
hk'✝ : k✝ < length (x' :: y' :: l')
k : ℕ
IH :
∀ (hk : k < length (rotate (x :: y :: l) n)) (hk' : k < length (x' :: y' :: l')),
nthLe (x :: y :: l) ((k + n) % length (x :: y :: l)) (_ : (k + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') k hk'
hk : Nat.succ k < length (rotate (x :: y :: l) n)
hk' : Nat.succ k < length (x' :: y' :: l')
this : Nat.succ k = (k + 1) % length (x' :: y' :: l')
⊢ nthLe (x :: y :: l) (((k + 1) % length (x' :: y' :: l') + n) % length (x :: y :: l))
(_ : ((k + 1) % length (x' :: y' :: l') + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x :: y :: l) (((k + n) % length (x :: y :: l) + 1) % length (x :: y :: l))
(_ : ((k + n) % length (x :: y :: l) + 1) % length (x :: y :: l) < length (x :: y :: l))
[PROOFSTEP]
congr 1
[GOAL]
case h.h.succ.e_n
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k✝ : ℕ
hk✝ : k✝ < length (rotate (x :: y :: l) n)
hk'✝ : k✝ < length (x' :: y' :: l')
k : ℕ
IH :
∀ (hk : k < length (rotate (x :: y :: l) n)) (hk' : k < length (x' :: y' :: l')),
nthLe (x :: y :: l) ((k + n) % length (x :: y :: l)) (_ : (k + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') k hk'
hk : Nat.succ k < length (rotate (x :: y :: l) n)
hk' : Nat.succ k < length (x' :: y' :: l')
this : Nat.succ k = (k + 1) % length (x' :: y' :: l')
⊢ ((k + 1) % length (x' :: y' :: l') + n) % length (x :: y :: l) =
((k + n) % length (x :: y :: l) + 1) % length (x :: y :: l)
[PROOFSTEP]
have h1 : 1 = 1 % (x' :: y' :: l').length := by simp
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k✝ : ℕ
hk✝ : k✝ < length (rotate (x :: y :: l) n)
hk'✝ : k✝ < length (x' :: y' :: l')
k : ℕ
IH :
∀ (hk : k < length (rotate (x :: y :: l) n)) (hk' : k < length (x' :: y' :: l')),
nthLe (x :: y :: l) ((k + n) % length (x :: y :: l)) (_ : (k + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') k hk'
hk : Nat.succ k < length (rotate (x :: y :: l) n)
hk' : Nat.succ k < length (x' :: y' :: l')
this : Nat.succ k = (k + 1) % length (x' :: y' :: l')
⊢ 1 = 1 % length (x' :: y' :: l')
[PROOFSTEP]
simp
[GOAL]
case h.h.succ.e_n
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y x' y' : α
l l' : List α
hd : Nodup (x :: y :: l)
hd' : Nodup (x' :: y' :: l')
h : ∀ (x_1 : α), ↑(formPerm (x :: y :: l)) x_1 = ↑(formPerm (x' :: y' :: l')) x_1
hx : x' ∈ x :: y :: l
n : ℕ
hn : n < length (x :: y :: l)
hx' : nthLe (x :: y :: l) n hn = x'
hl : length (x :: y :: l) = length (x' :: y' :: l')
k✝ : ℕ
hk✝ : k✝ < length (rotate (x :: y :: l) n)
hk'✝ : k✝ < length (x' :: y' :: l')
k : ℕ
IH :
∀ (hk : k < length (rotate (x :: y :: l) n)) (hk' : k < length (x' :: y' :: l')),
nthLe (x :: y :: l) ((k + n) % length (x :: y :: l)) (_ : (k + n) % length (x :: y :: l) < length (x :: y :: l)) =
nthLe (x' :: y' :: l') k hk'
hk : Nat.succ k < length (rotate (x :: y :: l) n)
hk' : Nat.succ k < length (x' :: y' :: l')
this : Nat.succ k = (k + 1) % length (x' :: y' :: l')
h1 : 1 = 1 % length (x' :: y' :: l')
⊢ ((k + 1) % length (x' :: y' :: l') + n) % length (x :: y :: l) =
((k + n) % length (x :: y :: l) + 1) % length (x :: y :: l)
[PROOFSTEP]
rw [hl, Nat.mod_eq_of_lt hk', h1, ← Nat.add_mod, Nat.succ_add, Nat.succ_eq_add_one]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : x ∈ l
⊢ ↑(formPerm l) x = x ↔ length l ≤ 1
[PROOFSTEP]
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
⊢ ↑(formPerm l) (nthLe l k hk) = nthLe l k hk ↔ length l ≤ 1
[PROOFSTEP]
rw [formPerm_apply_nthLe _ hl, hl.nthLe_inj_iff]
[GOAL]
case intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
⊢ (k + 1) % length l = k ↔ length l ≤ 1
[PROOFSTEP]
cases hn : l.length
[GOAL]
case intro.intro.zero
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
hn : length l = Nat.zero
⊢ (k + 1) % Nat.zero = k ↔ Nat.zero ≤ 1
[PROOFSTEP]
exact absurd k.zero_le (hk.trans_le hn.le).not_le
[GOAL]
case intro.intro.succ
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
n✝ : ℕ
hn : length l = Nat.succ n✝
⊢ (k + 1) % Nat.succ n✝ = k ↔ Nat.succ n✝ ≤ 1
[PROOFSTEP]
rw [hn] at hk
[GOAL]
case intro.intro.succ
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk✝ : k < length l
hx : nthLe l k hk✝ ∈ l
n✝ : ℕ
hk : k < Nat.succ n✝
hn : length l = Nat.succ n✝
⊢ (k + 1) % Nat.succ n✝ = k ↔ Nat.succ n✝ ≤ 1
[PROOFSTEP]
cases' (Nat.le_of_lt_succ hk).eq_or_lt with hk' hk'
[GOAL]
case intro.intro.succ.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk✝ : k < length l
hx : nthLe l k hk✝ ∈ l
n✝ : ℕ
hk : k < Nat.succ n✝
hn : length l = Nat.succ n✝
hk' : k = n✝
⊢ (k + 1) % Nat.succ n✝ = k ↔ Nat.succ n✝ ≤ 1
[PROOFSTEP]
simp [← hk', Nat.succ_le_succ_iff, eq_comm]
[GOAL]
case intro.intro.succ.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk✝ : k < length l
hx : nthLe l k hk✝ ∈ l
n✝ : ℕ
hk : k < Nat.succ n✝
hn : length l = Nat.succ n✝
hk' : k < n✝
⊢ (k + 1) % Nat.succ n✝ = k ↔ Nat.succ n✝ ≤ 1
[PROOFSTEP]
simpa [Nat.mod_eq_of_lt (Nat.succ_lt_succ hk'), Nat.succ_lt_succ_iff] using k.zero_le.trans_lt hk'
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : x ∈ l
⊢ ↑(formPerm l) x ≠ x ↔ 2 ≤ length l
[PROOFSTEP]
rw [Ne.def, formPerm_apply_mem_eq_self_iff _ hl x hx, not_le]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : x ∈ l
⊢ 1 < length l ↔ 2 ≤ length l
[PROOFSTEP]
exact ⟨Nat.succ_le_of_lt, Nat.lt_of_succ_le⟩
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
h : ↑(formPerm l) x ≠ x
⊢ x ∈ l
[PROOFSTEP]
suffices x ∈ {y | formPerm l y ≠ y} by
rw [← mem_toFinset]
exact support_formPerm_le' _ this
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
h : ↑(formPerm l) x ≠ x
this : x ∈ {y | ↑(formPerm l) y ≠ y}
⊢ x ∈ l
[PROOFSTEP]
rw [← mem_toFinset]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
h : ↑(formPerm l) x ≠ x
this : x ∈ {y | ↑(formPerm l) y ≠ y}
⊢ x ∈ toFinset l
[PROOFSTEP]
exact support_formPerm_le' _ this
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
h : ↑(formPerm l) x ≠ x
⊢ x ∈ {y | ↑(formPerm l) y ≠ y}
[PROOFSTEP]
simpa using h
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
⊢ formPerm l = 1 ↔ length l ≤ 1
[PROOFSTEP]
cases' l with hd tl
[GOAL]
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x : α
hl : Nodup []
⊢ formPerm [] = 1 ↔ length [] ≤ 1
[PROOFSTEP]
simp
[GOAL]
case cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
⊢ formPerm (hd :: tl) = 1 ↔ length (hd :: tl) ≤ 1
[PROOFSTEP]
rw [← formPerm_apply_mem_eq_self_iff _ hl hd (mem_cons_self _ _)]
[GOAL]
case cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
⊢ formPerm (hd :: tl) = 1 ↔ ↑(formPerm (hd :: tl)) hd = hd
[PROOFSTEP]
constructor
[GOAL]
case cons.mp
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
⊢ formPerm (hd :: tl) = 1 → ↑(formPerm (hd :: tl)) hd = hd
[PROOFSTEP]
simp (config := { contextual := true })
[GOAL]
case cons.mpr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
⊢ ↑(formPerm (hd :: tl)) hd = hd → formPerm (hd :: tl) = 1
[PROOFSTEP]
intro h
[GOAL]
case cons.mpr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
h : ↑(formPerm (hd :: tl)) hd = hd
⊢ formPerm (hd :: tl) = 1
[PROOFSTEP]
simp only [(hd :: tl).formPerm_apply_mem_eq_self_iff hl hd (mem_cons_self hd tl), add_le_iff_nonpos_left, length,
nonpos_iff_eq_zero, length_eq_zero] at h
[GOAL]
case cons.mpr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
x hd : α
tl : List α
hl : Nodup (hd :: tl)
h : tl = []
⊢ formPerm (hd :: tl) = 1
[PROOFSTEP]
simp [h]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x : α
l l' : List α
hl : Nodup l
hl' : Nodup l'
⊢ formPerm l = formPerm l' ↔ l ~r l' ∨ length l ≤ 1 ∧ length l' ≤ 1
[PROOFSTEP]
rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
[GOAL]
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
l' : List α
hl' : Nodup l'
hl : Nodup []
⊢ formPerm [] = formPerm l' ↔ [] ~r l' ∨ length [] ≤ 1 ∧ length l' ≤ 1
[PROOFSTEP]
suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
l' : List α
hl' : Nodup l'
hl : Nodup []
this : length l' ≤ 1 ↔ l' = [] ∨ length l' ≤ 1
⊢ formPerm [] = formPerm l' ↔ [] ~r l' ∨ length [] ≤ 1 ∧ length l' ≤ 1
[PROOFSTEP]
simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero]
[GOAL]
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
l' : List α
hl' : Nodup l'
hl : Nodup []
⊢ length l' ≤ 1 ↔ l' = [] ∨ length l' ≤ 1
[PROOFSTEP]
refine' ⟨fun h => Or.inr h, _⟩
[GOAL]
case nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
l' : List α
hl' : Nodup l'
hl : Nodup []
⊢ l' = [] ∨ length l' ≤ 1 → length l' ≤ 1
[PROOFSTEP]
rintro (rfl | h)
[GOAL]
case nil.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl hl' : Nodup []
⊢ length [] ≤ 1
[PROOFSTEP]
simp
[GOAL]
case nil.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
l' : List α
hl' : Nodup l'
hl : Nodup []
h : length l' ≤ 1
⊢ length l' ≤ 1
[PROOFSTEP]
exact h
[GOAL]
case cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
⊢ formPerm [x] = formPerm l' ↔ [x] ~r l' ∨ length [x] ≤ 1 ∧ length l' ≤ 1
[PROOFSTEP]
suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
this : length l' ≤ 1 ↔ [x] ~r l' ∨ length l' ≤ 1
⊢ formPerm [x] = formPerm l' ↔ [x] ~r l' ∨ length [x] ≤ 1 ∧ length l' ≤ 1
[PROOFSTEP]
simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero, le_rfl]
[GOAL]
case cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
⊢ length l' ≤ 1 ↔ [x] ~r l' ∨ length l' ≤ 1
[PROOFSTEP]
refine' ⟨fun h => Or.inr h, _⟩
[GOAL]
case cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
⊢ [x] ~r l' ∨ length l' ≤ 1 → length l' ≤ 1
[PROOFSTEP]
rintro (h | h)
[GOAL]
case cons.nil.inl
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
h : [x] ~r l'
⊢ length l' ≤ 1
[PROOFSTEP]
simp [← h.perm.length_eq]
[GOAL]
case cons.nil.inr
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
l' : List α
hl' : Nodup l'
x : α
hl : Nodup [x]
h : length l' ≤ 1
⊢ length l' ≤ 1
[PROOFSTEP]
exact h
[GOAL]
case cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l' : List α
hl' : Nodup l'
x y : α
l : List α
hl : Nodup (x :: y :: l)
⊢ formPerm (x :: y :: l) = formPerm l' ↔ (x :: y :: l) ~r l' ∨ length (x :: y :: l) ≤ 1 ∧ length l' ≤ 1
[PROOFSTEP]
rcases l' with (_ | ⟨x', _ | ⟨y', l'⟩⟩)
[GOAL]
case cons.cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y : α
l : List α
hl : Nodup (x :: y :: l)
hl' : Nodup []
⊢ formPerm (x :: y :: l) = formPerm [] ↔ (x :: y :: l) ~r [] ∨ length (x :: y :: l) ≤ 1 ∧ length [] ≤ 1
[PROOFSTEP]
simp [formPerm_eq_one_iff _ hl, -formPerm_cons_cons]
[GOAL]
case cons.cons.cons.nil
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y : α
l : List α
hl : Nodup (x :: y :: l)
x' : α
hl' : Nodup [x']
⊢ formPerm (x :: y :: l) = formPerm [x'] ↔ (x :: y :: l) ~r [x'] ∨ length (x :: y :: l) ≤ 1 ∧ length [x'] ≤ 1
[PROOFSTEP]
simp [formPerm_eq_one_iff _ hl, -formPerm_cons_cons]
[GOAL]
case cons.cons.cons.cons
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ x y : α
l : List α
hl : Nodup (x :: y :: l)
x' y' : α
l' : List α
hl' : Nodup (x' :: y' :: l')
⊢ formPerm (x :: y :: l) = formPerm (x' :: y' :: l') ↔
(x :: y :: l) ~r (x' :: y' :: l') ∨ length (x :: y :: l) ≤ 1 ∧ length (x' :: y' :: l') ≤ 1
[PROOFSTEP]
simp [-formPerm_cons_cons, formPerm_ext_iff hl hl', Nat.succ_le_succ_iff]
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
hx : x ∈ l
n : ℤ
⊢ ↑(formPerm l ^ n) x ∈ l
[PROOFSTEP]
by_cases h : (l.formPerm ^ n) x = x
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
hx : x ∈ l
n : ℤ
h : ↑(formPerm l ^ n) x = x
⊢ ↑(formPerm l ^ n) x ∈ l
[PROOFSTEP]
simpa [h] using hx
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
hx : x ∈ l
n : ℤ
h : ¬↑(formPerm l ^ n) x = x
⊢ ↑(formPerm l ^ n) x ∈ l
[PROOFSTEP]
have h : x ∈ {x | (l.formPerm ^ n) x ≠ x} := h
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
hx : x ∈ l
n : ℤ
h✝ : ¬↑(formPerm l ^ n) x = x
h : x ∈ {x | ↑(formPerm l ^ n) x ≠ x}
⊢ ↑(formPerm l ^ n) x ∈ l
[PROOFSTEP]
rw [← set_support_apply_mem] at h
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
hx : x ∈ l
n : ℤ
h✝ : ¬↑(formPerm l ^ n) x = x
h : ↑(formPerm l ^ n) x ∈ {x | ↑(formPerm l ^ n) x ≠ x}
⊢ ↑(formPerm l ^ n) x ∈ l
[PROOFSTEP]
replace h := set_support_zpow_subset _ _ h
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l✝ : List α
x✝ : α
l : List α
x : α
hx : x ∈ l
n : ℤ
h✝ : ¬↑(formPerm l ^ n) x = x
h : ↑(formPerm l ^ n) x ∈ {x_1 | ↑(formPerm l) x_1 ≠ x_1}
⊢ ↑(formPerm l ^ n) x ∈ l
[PROOFSTEP]
simpa using support_formPerm_le' _ h
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
⊢ formPerm l ^ length l = 1
[PROOFSTEP]
ext x
[GOAL]
case H
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
⊢ ↑(formPerm l ^ length l) x = ↑1 x
[PROOFSTEP]
by_cases hx : x ∈ l
[GOAL]
case pos
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : x ∈ l
⊢ ↑(formPerm l ^ length l) x = ↑1 x
[PROOFSTEP]
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
[GOAL]
case pos.intro.intro
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x : α
hl : Nodup l
k : ℕ
hk : k < length l
hx : nthLe l k hk ∈ l
⊢ ↑(formPerm l ^ length l) (nthLe l k hk) = ↑1 (nthLe l k hk)
[PROOFSTEP]
simp [formPerm_pow_apply_nthLe _ hl, Nat.mod_eq_of_lt hk]
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : ¬x ∈ l
⊢ ↑(formPerm l ^ length l) x = ↑1 x
[PROOFSTEP]
have : x ∉ {x | (l.formPerm ^ l.length) x ≠ x} := by
intro H
refine' hx _
replace H := set_support_zpow_subset l.formPerm l.length H
simpa using support_formPerm_le' _ H
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : ¬x ∈ l
⊢ ¬x ∈ {x | ↑(formPerm l ^ length l) x ≠ x}
[PROOFSTEP]
intro H
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : ¬x ∈ l
H : x ∈ {x | ↑(formPerm l ^ length l) x ≠ x}
⊢ False
[PROOFSTEP]
refine' hx _
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : ¬x ∈ l
H : x ∈ {x | ↑(formPerm l ^ length l) x ≠ x}
⊢ x ∈ l
[PROOFSTEP]
replace H := set_support_zpow_subset l.formPerm l.length H
[GOAL]
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : ¬x ∈ l
H : x ∈ {x | ↑(formPerm l) x ≠ x}
⊢ x ∈ l
[PROOFSTEP]
simpa using support_formPerm_le' _ H
[GOAL]
case neg
α : Type u_1
β : Type u_2
inst✝ : DecidableEq α
l : List α
x✝ : α
hl : Nodup l
x : α
hx : ¬x ∈ l
this : ¬x ∈ {x | ↑(formPerm l ^ length l) x ≠ x}
⊢ ↑(formPerm l ^ length l) x = ↑1 x
[PROOFSTEP]
simpa using this
|
/-
Copyright (c) 2019 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon, Yury Kudryashov
-/
import algebra.star.basic
/-!
# Free monoid over a given alphabet
## Main definitions
* `free_monoid α`: free monoid over alphabet `α`; defined as a synonym for `list α`
with multiplication given by `(++)`.
* `free_monoid.of`: embedding `α → free_monoid α` sending each element `x` to `[x]`;
* `free_monoid.lift`: natural equivalence between `α → M` and `free_monoid α →* M`
* `free_monoid.map`: embedding of `α → β` into `free_monoid α →* free_monoid β` given by `list.map`.
-/
variables {α : Type*} {β : Type*} {γ : Type*} {M : Type*} [monoid M] {N : Type*} [monoid N]
/-- Free monoid over a given alphabet. -/
@[to_additive "Free nonabelian additive monoid over a given alphabet"]
def free_monoid (α) := list α
namespace free_monoid
@[to_additive]
instance : monoid (free_monoid α) :=
{ one := [],
mul := λ x y, (x ++ y : list α),
mul_one := by intros; apply list.append_nil,
one_mul := by intros; refl,
mul_assoc := by intros; apply list.append_assoc }
@[to_additive]
instance : inhabited (free_monoid α) := ⟨1⟩
@[to_additive]
lemma one_def : (1 : free_monoid α) = [] := rfl
@[to_additive]
lemma mul_def (xs ys : list α) : (xs * ys : free_monoid α) = (xs ++ ys : list α) :=
rfl
/-- Embeds an element of `α` into `free_monoid α` as a singleton list. -/
@[to_additive "Embeds an element of `α` into `free_add_monoid α` as a singleton list." ]
def of (x : α) : free_monoid α := [x]
@[to_additive]
lemma of_def (x : α) : of x = [x] := rfl
@[to_additive]
lemma of_injective : function.injective (@of α) :=
λ a b, list.head_eq_of_cons_eq
/-- Recursor for `free_monoid` using `1` and `of x * xs` instead of `[]` and `x :: xs`. -/
@[elab_as_eliminator, to_additive
"Recursor for `free_add_monoid` using `0` and `of x + xs` instead of `[]` and `x :: xs`."]
def rec_on {C : free_monoid α → Sort*} (xs : free_monoid α) (h0 : C 1)
(ih : Π x xs, C xs → C (of x * xs)) : C xs := list.rec_on xs h0 ih
@[ext, to_additive]
lemma hom_eq ⦃f g : free_monoid α →* M⦄ (h : ∀ x, f (of x) = g (of x)) :
f = g :=
monoid_hom.ext $ λ l, rec_on l (f.map_one.trans g.map_one.symm) $
λ x xs hxs, by simp only [h, hxs, monoid_hom.map_mul]
/-- Equivalence between maps `α → M` and monoid homomorphisms `free_monoid α →* M`. -/
@[to_additive "Equivalence between maps `α → A` and additive monoid homomorphisms
`free_add_monoid α →+ A`."]
def lift : (α → M) ≃ (free_monoid α →* M) :=
{ to_fun := λ f, ⟨λ l, (l.map f).prod, rfl,
λ l₁ l₂, by simp only [mul_def, list.map_append, list.prod_append]⟩,
inv_fun := λ f x, f (of x),
left_inv := λ f, funext $ λ x, one_mul (f x),
right_inv := λ f, hom_eq $ λ x, one_mul (f (of x)) }
@[simp, to_additive]
lemma lift_symm_apply (f : free_monoid α →* M) : lift.symm f = f ∘ of := rfl
@[to_additive]
lemma lift_apply (f : α → M) (l : free_monoid α) : lift f l = (l.map f).prod := rfl
@[to_additive]
lemma lift_comp_of (f : α → M) : (lift f) ∘ of = f := lift.symm_apply_apply f
@[simp, to_additive]
lemma lift_eval_of (f : α → M) (x : α) : lift f (of x) = f x :=
congr_fun (lift_comp_of f) x
@[simp, to_additive]
lemma lift_restrict (f : free_monoid α →* M) : lift (f ∘ of) = f :=
lift.apply_symm_apply f
@[to_additive]
lemma comp_lift (g : M →* N) (f : α → M) : g.comp (lift f) = lift (g ∘ f) :=
by { ext, simp }
@[to_additive]
lemma hom_map_lift (g : M →* N) (f : α → M) (x : free_monoid α) : g (lift f x) = lift (g ∘ f) x :=
monoid_hom.ext_iff.1 (comp_lift g f) x
/-- The unique monoid homomorphism `free_monoid α →* free_monoid β` that sends
each `of x` to `of (f x)`. -/
@[to_additive "The unique additive monoid homomorphism `free_add_monoid α →+ free_add_monoid β`
that sends each `of x` to `of (f x)`."]
def map (f : α → β) : free_monoid α →* free_monoid β :=
{ to_fun := list.map f,
map_one' := rfl,
map_mul' := λ l₁ l₂, list.map_append _ _ _ }
@[simp, to_additive] lemma map_of (f : α → β) (x : α) : map f (of x) = of (f x) := rfl
@[to_additive]
lemma lift_of_comp_eq_map (f : α → β) :
lift (λ x, of (f x)) = map f :=
hom_eq $ λ x, rfl
@[to_additive]
lemma map_comp (g : β → γ) (f : α → β) : map (g ∘ f) = (map g).comp (map f) :=
hom_eq $ λ x, rfl
instance : star_monoid (free_monoid α) :=
{ star := list.reverse,
star_involutive := list.reverse_reverse,
star_mul := list.reverse_append, }
@[simp]
lemma star_of (x : α) : star (of x) = of x := rfl
/-- Note that `star_one` is already a global simp lemma, but this one works with dsimp too -/
@[simp]
lemma star_one : star (1 : free_monoid α) = 1 := rfl
end free_monoid
|
import phase0.support
/-!
# Phase 1 of the recursion
This file contains the induction hypothesis for the first phase of the recursion. In this phase at
level `α`, we assume phase 1 at all levels `β < α`, but we do not assume any interaction between the
levels. Interaction will be introduced in phase 2.
## Main declarations
* `con_nf.core_tangle_data`:
* `con_nf.positioned_tangle_data`:
* `con_nf.almost_tangle_data`:
* `con_nf.tangle_data`: The data for the first phase of the recursion.
-/
open function set with_bot
noncomputable theory
universe u
namespace con_nf
variable [params.{u}]
section define_tangle_data
/-- The motor of the initial recursion. This contains the data of tangles and allowable permutations
for phase 1 of the recursion. -/
class core_tangle_data (α : type_index) :=
(tangle allowable : Type u)
[allowable_group : group allowable]
(allowable_to_struct_perm : allowable →* struct_perm α)
[allowable_action : mul_action allowable tangle]
(designated_support : by { haveI : mul_action allowable (support_condition α) :=
mul_action.comp_hom _ allowable_to_struct_perm, exact Π t : tangle, support α allowable t })
export core_tangle_data (tangle allowable designated_support)
attribute [instance] core_tangle_data.allowable_group core_tangle_data.allowable_action
section
variables (α : type_index) [core_tangle_data α]
/-- The type of allowable permutations that we assume exists on `α`-tangles. -/
def allowable : Type u := core_tangle_data.allowable α
/-- Allowable permutations at level `α` forms a group with respect to function composition. Note
that at this stage in the recursion, we have not established that the allowable permutations on
`α`-tangles are actually (coercible to) functions, so we cannot compose them with the `∘` symbol; we
must instead use group multiplication `*`. -/
instance : group (allowable α) := core_tangle_data.allowable_group
variables {α} {X : Type*} [mul_action (struct_perm α) X]
namespace allowable
/-- Allowable permutations can be considered a subtype of structural permutations. However, we
cannot write this explicitly in type theory, so instead we assume this monoid homomorphism from
allowable permutations to structural permutations. This can be thought of as an inclusion map that
preserves the group structure. This allows allowable permutations to act on pretangles. -/
def to_struct_perm : allowable α →* struct_perm α := core_tangle_data.allowable_to_struct_perm
instance : mul_action (allowable α) (tangle α) := core_tangle_data.allowable_action
/-- Allowable permutations act on tangles. This action commutes with certain other operations; the
exact conditions are given in `smul_typed_near_litter` and `smul_pretangle_inj`. -/
instance : mul_action (allowable α) X := mul_action.comp_hom _ to_struct_perm
@[simp] lemma to_struct_perm_smul (f : allowable α) (x : X) : f.to_struct_perm • x = f • x := rfl
end allowable
/-- For each tangle, we provide a small support for it. This is known as the designated support of
the tangle. -/
def designated_support (t : tangle α) : support α (allowable α) t :=
core_tangle_data.designated_support _
end
/-- The motor of the initial recursion. This contains the data of the position function. -/
class positioned_tangle_data (α : type_index) [core_tangle_data α] :=
(position : tangle α ↪ μ)
export positioned_tangle_data (position)
variables (α : Λ) [core_tangle_data α]
/-- The motor of the initial recursion. This contains the data of the injection to all the
information needed for phase 1 of the recursion. -/
class almost_tangle_data :=
(typed_atom : atom ↪ tangle α)
(typed_near_litter : near_litter ↪ tangle α)
(smul_typed_near_litter :
Π (π : allowable α) N, π • typed_near_litter N = typed_near_litter (π • N))
(pretangle_inj : tangle α ↪ pretangle α)
(smul_pretangle_inj : Π (π : allowable α) (t : tangle α),
π • pretangle_inj t = pretangle_inj (π • t))
export almost_tangle_data (typed_atom typed_near_litter pretangle_inj)
namespace allowable
variables {α} [almost_tangle_data α]
/-- The action of allowable permutations on tangles commutes with the `typed_near_litter` function mapping
near-litters to typed near-litters. This is quite clear to see when representing tangles as codes,
but since at this stage tangles are just a type, we have to state this condition explicitly. -/
lemma smul_typed_near_litter (π : allowable α) (N : near_litter) :
π • (typed_near_litter N : tangle α) = typed_near_litter (π • N) :=
almost_tangle_data.smul_typed_near_litter _ _
/-- The action of allowable permutations on tangles commutes with the `pretangle_inj` injection
converting tangles into pretangles. -/
lemma smul_pretangle_inj (π : allowable α) (t : tangle α) :
π • pretangle_inj t = pretangle_inj (π • t) := almost_tangle_data.smul_pretangle_inj _ _
end allowable
/-- The position of typed atoms and typed near-litters in the position function at any level.
This is part of the `γ = -1` fix. -/
class position_data :=
(typed_atom_position : atom ↪ μ)
(typed_near_litter_position : near_litter ↪ μ)
(litter_lt : ∀ (L : litter) (a ∈ litter_set L),
typed_near_litter_position L.to_near_litter < typed_atom_position a)
(litter_le_near_litter : ∀ (N : near_litter),
typed_near_litter_position N.fst.to_near_litter ≤ typed_near_litter_position N)
(symm_diff_lt_near_litter : ∀ (N : near_litter) (a ∈ litter_set N.fst ∆ N.snd),
typed_atom_position a < typed_near_litter_position N)
export position_data (typed_atom_position typed_near_litter_position
litter_lt litter_le_near_litter symm_diff_lt_near_litter)
lemma litter_lt_near_litter [position_data] (N : near_litter) (hN : N.fst.to_near_litter ≠ N) :
typed_near_litter_position N.fst.to_near_litter < typed_near_litter_position N :=
lt_of_le_of_ne (litter_le_near_litter N) (typed_near_litter_position.injective.ne hN)
variables [almost_tangle_data α] [positioned_tangle_data α] [position_data.{}]
/-- The motor of the initial recursion. This contains all the information needed for phase 1 of the
recursion. -/
class tangle_data : Prop :=
(typed_atom_position_eq : ∀ (a : atom),
position (typed_atom a : tangle α) = typed_atom_position a)
(typed_near_litter_position_eq : ∀ (N : near_litter),
position (typed_near_litter N : tangle α) = typed_near_litter_position N)
(support_le : Π (t : tangle α) (c : support_condition α) (hc : c ∈ designated_support t),
c.fst.elim typed_atom_position typed_near_litter_position ≤ position t)
/-- The type of tangles that we assume were constructed at stage `α`.
Later in the recursion, we will construct this type explicitly, but for now, we will just assume
that it exists.
Fields in `tangle_data` give more information about this type. -/
add_decl_doc core_tangle_data.tangle
/-- An injection from near-litters into level `α` tangles.
These will be explicitly constructed as "typed near-litters", which are codes of the form
`(α, -1, N)` for `N` a near-litter.
Since we haven't assumed anything about the structure of tangles at this level, we can't construct
these typed near-litters explicitly, so we rely on this function instead. In the blueprint, this is
function `j`. -/
add_decl_doc almost_tangle_data.typed_near_litter
/-- Tangles can be considered a subtype of pretangles, which are tangles without extensionality and
which are guaranteed to have a `-1`-extension. This injection can be seen as an inclusion map.
Since pretangles have a membership relation, we can use this map to see the members of a tangle at
any given level, by first converting it to a pretangle. -/
add_decl_doc almost_tangle_data.pretangle_inj
/-- For any atom `a`, we can construct an `α`-tangle that has a `-1`-extension that contains exactly
this atom. This is called a typed singleton. In the blueprint, this is the function `k`. -/
add_decl_doc almost_tangle_data.typed_atom
/-- An injection from level `α` tangles into the type `μ`.
Since `μ` has a well-ordering, this induces a well-ordering on `α`-tangles: to compare two tangles,
simply compare their images under this map.
Conditions satisfied by this injection are given in `litter_lt`, `litter_lt_near_litter`,
`symm_diff_lt_near_litter`, and `support_le`. In the blueprint, this is function `ι`. -/
add_decl_doc positioned_tangle_data.position
/-- Each typed litter `L` precedes the typed singletons of all of its elements `a ∈ L`. -/
add_decl_doc position_data.litter_lt
/-- Each near litter `N` which is not a litter comes later than its associated liter `L = N°`. -/
add_decl_doc litter_lt_near_litter
/-- Each near litter `N` comes after all elements in the symmetric difference `N ∆ N°` (which is
a small set by construction). Note that if `N` is a litter, this condition is vacuously true. -/
add_decl_doc symm_diff_lt_near_litter
/-- For all tangles `t` that are not typed singletons and not typed litters, `t` comes later than
all of the support conditions in its designated support. That is, if an atom `a` is in the
designated support for `t`, then `t` lies after `a`, and if a near-litter `N` is in the designated
support for `t`, then `t` lies after `N` (under suitable maps to `μ`). -/
add_decl_doc tangle_data.support_le
end define_tangle_data
section instances
variables {α : Λ} (β : Iio α) [core_tangle_data (Iio_coe β)]
instance core_val : core_tangle_data β.val := ‹core_tangle_data β›
instance core_coe_coe : core_tangle_data (β : Λ) := ‹core_tangle_data β›
section positioned_tangle_data
variables [positioned_tangle_data (Iio_coe β)]
instance positioned_val : positioned_tangle_data β.val := ‹positioned_tangle_data _›
instance positioned_coe_coe : positioned_tangle_data (β : Λ) := ‹positioned_tangle_data _›
end positioned_tangle_data
variables [almost_tangle_data β]
instance almost_val : almost_tangle_data β.val := ‹almost_tangle_data β›
end instances
/-- The tangle data at level `⊥` is constructed by taking the tangles to be the atoms, the allowable
permutations to be near-litter-permutations, and the designated supports to be singletons. -/
instance bot.core_tangle_data : core_tangle_data ⊥ :=
{ tangle := atom,
allowable := near_litter_perm,
allowable_to_struct_perm := struct_perm.to_bot_iso.to_monoid_hom,
allowable_action := infer_instance,
designated_support := λ a,
{ carrier := {to_condition (sum.inl a, quiver.path.nil)},
supports := λ π, by simp only [mem_singleton_iff, has_smul.comp.smul,
mul_equiv.coe_to_monoid_hom, struct_perm.coe_to_bot_iso, equiv.to_fun_as_coe,
forall_eq, struct_perm.smul_to_condition, struct_perm.derivative_nil,
struct_perm.to_bot_smul, sum.smul_inl, embedding_like.apply_eq_iff_eq, prod.mk.inj_iff,
eq_self_iff_true, and_true, imp_self],
small := small_singleton _ } }
/-- The tangle data at the bottom level. -/
instance bot.positioned_tangle_data : positioned_tangle_data ⊥ := ⟨nonempty.some mk_atom.le⟩
variables (α : Λ)
/-- The core tangle data below phase `α`. -/
class core_tangle_cumul (α : Λ) := (data : Π β : Iio α, core_tangle_data β)
section core_tangle_cumul
variables [core_tangle_cumul α]
instance core_tangle_cumul.to_core_tangle_data : Π β : Iio_index α, core_tangle_data β
| ⟨⊥, h⟩ := bot.core_tangle_data
| ⟨(β : Λ), hβ⟩ := core_tangle_cumul.data ⟨β, coe_lt_coe.1 hβ⟩
instance core_tangle_cumul.to_core_tangle_data' (β : Iio α) : core_tangle_data β :=
show core_tangle_data (Iio_coe β), by apply_instance
end core_tangle_cumul
/-- The positioned tangle data below phase `α`. -/
class positioned_tangle_cumul (α : Λ) [core_tangle_cumul α] :=
(data : Π β : Iio α, positioned_tangle_data β)
section positioned_tangle_cumul
variables [core_tangle_cumul α] [positioned_tangle_cumul α]
instance positioned_tangle_cumul.to_positioned_tangle_data :
Π β : Iio_index α, positioned_tangle_data β
| ⟨⊥, h⟩ := bot.positioned_tangle_data
| ⟨(β : Λ), hβ⟩ := positioned_tangle_cumul.data ⟨β, coe_lt_coe.1 hβ⟩
instance positioned_tangle_cumul.to_positioned_tangle_data' (β : Iio α) :
positioned_tangle_data β :=
show positioned_tangle_data (Iio_coe β), by apply_instance
end positioned_tangle_cumul
/-- The almost tangle data below phase `α`. -/
abbreviation almost_tangle_cumul (α : Λ) [core_tangle_cumul α] := Π β : Iio α, almost_tangle_data β
/-- The tangle data below phase `α`. -/
abbreviation tangle_cumul (α : Λ) [core_tangle_cumul α] [positioned_tangle_cumul α]
[position_data.{}] [almost_tangle_cumul α] := Π β : Iio α, tangle_data β
end con_nf
|
rename.bio.snowcrab.variables = function(oldnames) {
lookupnames = snowcrab.lookupnames()
oldnames = tolower( oldnames )
newnames = oldnames
nvars = length(oldnames)
for (i in 1:nvars) {
j = which(lookupnames[,1] == oldnames[i])
if (length(j)>0) newnames[i] = lookupnames[j,2]
}
return (newnames)
}
|
State Before: α : Type u_1
inst✝¹ : Zero α
inst✝ : LinearOrder α
a : α
⊢ ↑sign a = 0 ↔ a = 0 State After: α : Type u_1
inst✝¹ : Zero α
inst✝ : LinearOrder α
a : α
h : ↑sign a = 0
⊢ a = 0 Tactic: refine' ⟨fun h => _, fun h => h.symm ▸ sign_zero⟩ State Before: α : Type u_1
inst✝¹ : Zero α
inst✝ : LinearOrder α
a : α
h : ↑sign a = 0
⊢ a = 0 State After: α : Type u_1
inst✝¹ : Zero α
inst✝ : LinearOrder α
a : α
h : (if 0 < a then 1 else if a < 0 then -1 else 0) = 0
⊢ a = 0 Tactic: rw [sign_apply] at h State Before: α : Type u_1
inst✝¹ : Zero α
inst✝ : LinearOrder α
a : α
h : (if 0 < a then 1 else if a < 0 then -1 else 0) = 0
⊢ a = 0 State After: case inr.inr
α : Type u_1
inst✝¹ : Zero α
inst✝ : LinearOrder α
a : α
h_1 : ¬0 < a
h_2 : ¬a < 0
h : 0 = 0
⊢ a = 0 Tactic: split_ifs at h with h_1 h_2 State Before: case inr.inr
α : Type u_1
inst✝¹ : Zero α
inst✝ : LinearOrder α
a : α
h_1 : ¬0 < a
h_2 : ¬a < 0
h : 0 = 0
⊢ a = 0 State After: case inr.inr.refl
α : Type u_1
inst✝¹ : Zero α
inst✝ : LinearOrder α
a : α
h_1 : ¬0 < a
h_2 : ¬a < 0
⊢ a = 0 Tactic: cases' h State Before: case inr.inr.refl
α : Type u_1
inst✝¹ : Zero α
inst✝ : LinearOrder α
a : α
h_1 : ¬0 < a
h_2 : ¬a < 0
⊢ a = 0 State After: no goals Tactic: exact (le_of_not_lt h_1).eq_of_not_lt h_2 |
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import order.filter.cofinite
/-!
# Computational realization of filters (experimental)
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
This file provides infrastructure to compute with filters.
## Main declarations
* `cfilter`: Realization of a filter base. Note that this is in the generality of filters on
lattices, while `filter` is filters of sets (so corresponding to `cfilter (set α) σ`).
* `filter.realizer`: Realization of a `filter`. `cfilter` that generates the given filter.
-/
open set filter
/-- A `cfilter α σ` is a realization of a filter (base) on `α`,
represented by a type `σ` together with operations for the top element and
the binary inf operation. -/
structure cfilter (α σ : Type*) [partial_order α] :=
(f : σ → α)
(pt : σ)
(inf : σ → σ → σ)
(inf_le_left : ∀ a b : σ, f (inf a b) ≤ f a)
(inf_le_right : ∀ a b : σ, f (inf a b) ≤ f b)
variables {α : Type*} {β : Type*} {σ : Type*} {τ : Type*}
instance [inhabited α] [semilattice_inf α] : inhabited (cfilter α α) :=
⟨{ f := id,
pt := default,
inf := (⊓),
inf_le_left := λ _ _, inf_le_left,
inf_le_right := λ _ _, inf_le_right }⟩
namespace cfilter
section
variables [partial_order α] (F : cfilter α σ)
instance : has_coe_to_fun (cfilter α σ) (λ _, σ → α) := ⟨cfilter.f⟩
@[simp] theorem coe_mk (f pt inf h₁ h₂ a) : (@cfilter.mk α σ _ f pt inf h₁ h₂) a = f a := rfl
/-- Map a cfilter to an equivalent representation type. -/
def of_equiv (E : σ ≃ τ) : cfilter α σ → cfilter α τ
| ⟨f, p, g, h₁, h₂⟩ :=
{ f := λ a, f (E.symm a),
pt := E p,
inf := λ a b, E (g (E.symm a) (E.symm b)),
inf_le_left := λ a b, by simpa using h₁ (E.symm a) (E.symm b),
inf_le_right := λ a b, by simpa using h₂ (E.symm a) (E.symm b) }
@[simp] theorem of_equiv_val (E : σ ≃ τ) (F : cfilter α σ) (a : τ) :
F.of_equiv E a = F (E.symm a) := by cases F; refl
end
/-- The filter represented by a `cfilter` is the collection of supersets of
elements of the filter base. -/
def to_filter (F : cfilter (set α) σ) : filter α :=
{ sets := {a | ∃ b, F b ⊆ a},
univ_sets := ⟨F.pt, subset_univ _⟩,
sets_of_superset := λ x y ⟨b, h⟩ s, ⟨b, subset.trans h s⟩,
inter_sets := λ x y ⟨a, h₁⟩ ⟨b, h₂⟩, ⟨F.inf a b,
subset_inter (subset.trans (F.inf_le_left _ _) h₁) (subset.trans (F.inf_le_right _ _) h₂)⟩ }
@[simp] theorem mem_to_filter_sets (F : cfilter (set α) σ) {a : set α} :
a ∈ F.to_filter ↔ ∃ b, F b ⊆ a := iff.rfl
end cfilter
/-- A realizer for filter `f` is a cfilter which generates `f`. -/
structure filter.realizer (f : filter α) :=
(σ : Type*)
(F : cfilter (set α) σ)
(eq : F.to_filter = f)
/-- A `cfilter` realizes the filter it generates. -/
protected def cfilter.to_realizer (F : cfilter (set α) σ) : F.to_filter.realizer := ⟨σ, F, rfl⟩
namespace filter.realizer
theorem mem_sets {f : filter α} (F : f.realizer) {a : set α} : a ∈ f ↔ ∃ b, F.F b ⊆ a :=
by cases F; subst f; simp
/-- Transfer a realizer along an equality of filter. This has better definitional equalities than
the `eq.rec` proof. -/
def of_eq {f g : filter α} (e : f = g) (F : f.realizer) : g.realizer :=
⟨F.σ, F.F, F.eq.trans e⟩
/-- A filter realizes itself. -/
def of_filter (f : filter α) : f.realizer := ⟨f.sets,
{ f := subtype.val,
pt := ⟨univ, univ_mem⟩,
inf := λ ⟨x, h₁⟩ ⟨y, h₂⟩, ⟨_, inter_mem h₁ h₂⟩,
inf_le_left := λ ⟨x, h₁⟩ ⟨y, h₂⟩, inter_subset_left x y,
inf_le_right := λ ⟨x, h₁⟩ ⟨y, h₂⟩, inter_subset_right x y },
filter_eq $ set.ext $ λ x, set_coe.exists.trans exists_mem_subset_iff⟩
/-- Transfer a filter realizer to another realizer on a different base type. -/
def of_equiv {f : filter α} (F : f.realizer) (E : F.σ ≃ τ) : f.realizer :=
⟨τ, F.F.of_equiv E, by refine eq.trans _ F.eq; exact filter_eq (set.ext $ λ x,
⟨λ ⟨s, h⟩, ⟨E.symm s, by simpa using h⟩, λ ⟨t, h⟩, ⟨E t, by simp [h]⟩⟩)⟩
@[simp] theorem of_equiv_σ {f : filter α} (F : f.realizer) (E : F.σ ≃ τ) :
(F.of_equiv E).σ = τ := rfl
@[simp]
/-- `unit` is a realizer for the principal filter -/
protected def principal (s : set α) : (principal s).realizer := ⟨unit,
{ f := λ _, s,
pt := (),
inf := λ _ _, (),
inf_le_left := λ _ _, le_rfl,
inf_le_right := λ _ _, le_rfl },
filter_eq $ set.ext $ λ x,
⟨λ ⟨_, s⟩, s, λ h, ⟨(), h⟩⟩⟩
@[simp] theorem principal_σ (s : set α) : (realizer.principal s).σ = unit := rfl
@[simp] theorem principal_F (s : set α) (u : unit) : (realizer.principal s).F u = s := rfl
instance (s : set α) : inhabited (principal s).realizer := ⟨realizer.principal s⟩
/-- `unit` is a realizer for the top filter -/
protected def top : (⊤ : filter α).realizer :=
(realizer.principal _).of_eq principal_univ
@[simp] theorem top_σ : (@realizer.top α).σ = unit := rfl
@[simp] theorem top_F (u : unit) : (@realizer.top α).F u = univ := rfl
/-- `unit` is a realizer for the bottom filter -/
protected def bot : (⊥ : filter α).realizer :=
(realizer.principal _).of_eq principal_empty
@[simp] theorem bot_σ : (@realizer.bot α).σ = unit := rfl
@[simp] theorem bot_F (u : unit) : (@realizer.bot α).F u = ∅ := rfl
/-- Construct a realizer for `map m f` given a realizer for `f` -/
protected def map (m : α → β) {f : filter α} (F : f.realizer) : (map m f).realizer := ⟨F.σ,
{ f := λ s, image m (F.F s),
pt := F.F.pt,
inf := F.F.inf,
inf_le_left := λ a b, image_subset _ (F.F.inf_le_left _ _),
inf_le_right := λ a b, image_subset _ (F.F.inf_le_right _ _) },
filter_eq $ set.ext $ λ x, by simp [cfilter.to_filter]; rw F.mem_sets; refl ⟩
@[simp] theorem map_σ (m : α → β) {f : filter α} (F : f.realizer) : (F.map m).σ = F.σ := rfl
@[simp] theorem map_F (m : α → β) {f : filter α} (F : f.realizer) (s) :
(F.map m).F s = image m (F.F s) := rfl
/-- Construct a realizer for `comap m f` given a realizer for `f` -/
protected def comap (m : α → β) {f : filter β} (F : f.realizer) : (comap m f).realizer := ⟨F.σ,
{ f := λ s, preimage m (F.F s),
pt := F.F.pt,
inf := F.F.inf,
inf_le_left := λ a b, preimage_mono (F.F.inf_le_left _ _),
inf_le_right := λ a b, preimage_mono (F.F.inf_le_right _ _) },
filter_eq $ set.ext $ λ x, by cases F; subst f; simp [cfilter.to_filter, mem_comap]; exact
⟨λ ⟨s, h⟩, ⟨_, ⟨s, subset.refl _⟩, h⟩,
λ ⟨y, ⟨s, h⟩, h₂⟩, ⟨s, subset.trans (preimage_mono h) h₂⟩⟩⟩
/-- Construct a realizer for the sup of two filters -/
protected def sup {f g : filter α} (F : f.realizer) (G : g.realizer) :
(f ⊔ g).realizer := ⟨F.σ × G.σ,
{ f := λ ⟨s, t⟩, F.F s ∪ G.F t,
pt := (F.F.pt, G.F.pt),
inf := λ ⟨a, a'⟩ ⟨b, b'⟩, (F.F.inf a b, G.F.inf a' b'),
inf_le_left := λ ⟨a, a'⟩ ⟨b, b'⟩, union_subset_union (F.F.inf_le_left _ _) (G.F.inf_le_left _ _),
inf_le_right := λ ⟨a, a'⟩ ⟨b, b'⟩, union_subset_union (F.F.inf_le_right _ _)
(G.F.inf_le_right _ _) },
filter_eq $ set.ext $ λ x, by cases F; cases G; substs f g; simp [cfilter.to_filter]; exact
⟨λ ⟨s, t, h⟩, ⟨⟨s, subset.trans (subset_union_left _ _) h⟩,
⟨t, subset.trans (subset_union_right _ _) h⟩⟩,
λ ⟨⟨s, h₁⟩, ⟨t, h₂⟩⟩, ⟨s, t, union_subset h₁ h₂⟩⟩⟩
/-- Construct a realizer for the inf of two filters -/
protected def inf {f g : filter α} (F : f.realizer) (G : g.realizer) :
(f ⊓ g).realizer := ⟨F.σ × G.σ,
{ f := λ ⟨s, t⟩, F.F s ∩ G.F t,
pt := (F.F.pt, G.F.pt),
inf := λ ⟨a, a'⟩ ⟨b, b'⟩, (F.F.inf a b, G.F.inf a' b'),
inf_le_left := λ ⟨a, a'⟩ ⟨b, b'⟩, inter_subset_inter (F.F.inf_le_left _ _) (G.F.inf_le_left _ _),
inf_le_right := λ ⟨a, a'⟩ ⟨b, b'⟩, inter_subset_inter (F.F.inf_le_right _ _)
(G.F.inf_le_right _ _) },
begin
ext x,
cases F; cases G; substs f g; simp [cfilter.to_filter],
split,
{ rintro ⟨s : F_σ, t : G_σ, h⟩,
apply mem_inf_of_inter _ _ h,
use s,
use t, },
{ rintros ⟨s, ⟨a, ha⟩, t, ⟨b, hb⟩, rfl⟩,
exact ⟨a, b, inter_subset_inter ha hb⟩ }
end⟩
/-- Construct a realizer for the cofinite filter -/
protected def cofinite [decidable_eq α] : (@cofinite α).realizer := ⟨finset α,
{ f := λ s, {a | a ∉ s},
pt := ∅,
inf := (∪),
inf_le_left := λ s t a, mt (finset.mem_union_left _),
inf_le_right := λ s t a, mt (finset.mem_union_right _) },
filter_eq $ set.ext $ λ x,
⟨λ ⟨s, h⟩, s.finite_to_set.subset (compl_subset_comm.1 h),
λ h, ⟨h.to_finset, by simp⟩⟩⟩
/-- Construct a realizer for filter bind -/
protected def bind {f : filter α} {m : α → filter β} (F : f.realizer) (G : ∀ i, (m i).realizer) :
(f.bind m).realizer :=
⟨Σ s : F.σ, Π i ∈ F.F s, (G i).σ,
{ f := λ ⟨s, f⟩, ⋃ i ∈ F.F s, (G i).F (f i H),
pt := ⟨F.F.pt, λ i H, (G i).F.pt⟩,
inf := λ ⟨a, f⟩ ⟨b, f'⟩, ⟨F.F.inf a b, λ i h,
(G i).F.inf (f i (F.F.inf_le_left _ _ h)) (f' i (F.F.inf_le_right _ _ h))⟩,
inf_le_left := λ ⟨a, f⟩ ⟨b, f'⟩ x,
show (x ∈ ⋃ (i : α) (H : i ∈ F.F (F.F.inf a b)), _) →
x ∈ ⋃ i (H : i ∈ F.F a), ((G i).F) (f i H), by simp; exact
λ i h₁ h₂, ⟨i, F.F.inf_le_left _ _ h₁, (G i).F.inf_le_left _ _ h₂⟩,
inf_le_right := λ ⟨a, f⟩ ⟨b, f'⟩ x,
show (x ∈ ⋃ (i : α) (H : i ∈ F.F (F.F.inf a b)), _) →
x ∈ ⋃ i (H : i ∈ F.F b), ((G i).F) (f' i H), by simp; exact
λ i h₁ h₂, ⟨i, F.F.inf_le_right _ _ h₁, (G i).F.inf_le_right _ _ h₂⟩ },
filter_eq $ set.ext $ λ x,
by cases F with _ F _; subst f; simp [cfilter.to_filter, mem_bind]; exact
⟨λ ⟨s, f, h⟩, ⟨F s, ⟨s, subset.refl _⟩, λ i H, (G i).mem_sets.2
⟨f i H, λ a h', h ⟨_, ⟨i, rfl⟩, _, ⟨H, rfl⟩, h'⟩⟩⟩,
λ ⟨y, ⟨s, h⟩, f⟩,
let ⟨f', h'⟩ := classical.axiom_of_choice (λ i:F s, (G i).mem_sets.1 (f i (h i.2))) in
⟨s, λ i h, f' ⟨i, h⟩, λ a ⟨_, ⟨i, rfl⟩, _, ⟨H, rfl⟩, m⟩, h' ⟨_, H⟩ m⟩⟩⟩
/-- Construct a realizer for indexed supremum -/
protected def Sup {f : α → filter β} (F : ∀ i, (f i).realizer) : (⨆ i, f i).realizer :=
let F' : (⨆ i, f i).realizer :=
((realizer.bind realizer.top F).of_eq $
filter_eq $ set.ext $ by simp [filter.bind, eq_univ_iff_forall, supr_sets_eq]) in
F'.of_equiv $ show (Σ u:unit, Π (i : α), true → (F i).σ) ≃ Π i, (F i).σ, from
⟨λ⟨_,f⟩ i, f i ⟨⟩, λ f, ⟨(), λ i _, f i⟩,
λ ⟨⟨⟩, f⟩, by dsimp; congr; simp, λ f, rfl⟩
/-- Construct a realizer for the product of filters -/
protected def prod {f g : filter α} (F : f.realizer) (G : g.realizer) : (f.prod g).realizer :=
(F.comap _).inf (G.comap _)
theorem le_iff {f g : filter α} (F : f.realizer) (G : g.realizer) :
f ≤ g ↔ ∀ b : G.σ, ∃ a : F.σ, F.F a ≤ G.F b :=
⟨λ H t, F.mem_sets.1 (H (G.mem_sets.2 ⟨t, subset.refl _⟩)),
λ H x h, F.mem_sets.2 $
let ⟨s, h₁⟩ := G.mem_sets.1 h, ⟨t, h₂⟩ := H s in ⟨t, subset.trans h₂ h₁⟩⟩
theorem tendsto_iff (f : α → β) {l₁ : filter α} {l₂ : filter β} (L₁ : l₁.realizer)
(L₂ : l₂.realizer) :
tendsto f l₁ l₂ ↔ ∀ b, ∃ a, ∀ x ∈ L₁.F a, f x ∈ L₂.F b :=
(le_iff (L₁.map f) L₂).trans $ forall_congr $ λ b, exists_congr $ λ a, image_subset_iff
theorem ne_bot_iff {f : filter α} (F : f.realizer) :
f ≠ ⊥ ↔ ∀ a : F.σ, (F.F a).nonempty :=
begin
classical,
rw [not_iff_comm, ← le_bot_iff, F.le_iff realizer.bot, not_forall],
simp only [set.not_nonempty_iff_eq_empty],
exact ⟨λ ⟨x, e⟩ _, ⟨x, le_of_eq e⟩,
λ h, let ⟨x, h⟩ := h () in ⟨x, le_bot_iff.1 h⟩⟩
end
end filter.realizer
|
[STATEMENT]
lemma preserves_circ:
"preserves x (-p) \<Longrightarrow> preserves (x\<^sup>\<circ>) (-p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. preserves x (- p) \<Longrightarrow> preserves (x\<^sup>\<circ>) (- p)
[PROOF STEP]
by (meson circ_simulate preserves_def) |
If $v$ is a real vector and $a \neq 0$, then $av = bv$ if and only if $a = b$. |
[STATEMENT]
lemma continuous_open_preimage:
assumes contf: "continuous_on S f" and "open S" "open T"
shows "open (S \<inter> f -` T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. open (S \<inter> f -` T)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
1. open (S \<inter> f -` T)
[PROOF STEP]
obtain U where "open U" "(S \<inter> f -` T) = S \<inter> U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (\<And>U. \<lbrakk>open U; S \<inter> f -` T = S \<inter> U\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using continuous_openin_preimage_gen[OF contf \<open>open T\<close>]
[PROOF STATE]
proof (prove)
using this:
openin (top_of_set S) (S \<inter> f -` T)
goal (1 subgoal):
1. (\<And>U. \<lbrakk>open U; S \<inter> f -` T = S \<inter> U\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding openin_open
[PROOF STATE]
proof (prove)
using this:
\<exists>Ta. open Ta \<and> S \<inter> f -` T = S \<inter> Ta
goal (1 subgoal):
1. (\<And>U. \<lbrakk>open U; S \<inter> f -` T = S \<inter> U\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
open U
S \<inter> f -` T = S \<inter> U
goal (1 subgoal):
1. open (S \<inter> f -` T)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
open U
S \<inter> f -` T = S \<inter> U
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
open U
S \<inter> f -` T = S \<inter> U
goal (1 subgoal):
1. open (S \<inter> f -` T)
[PROOF STEP]
using open_Int[of S U, OF \<open>open S\<close>]
[PROOF STATE]
proof (prove)
using this:
open U
S \<inter> f -` T = S \<inter> U
open U \<Longrightarrow> open (S \<inter> U)
goal (1 subgoal):
1. open (S \<inter> f -` T)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
open (S \<inter> f -` T)
goal:
No subgoals!
[PROOF STEP]
qed |
The last sentence of the passage is similar to one from the Republican era Biography of Song Yue , Prince of E. But instead of teaching them his own technique , it states Yue taught what he had learned from Zhou to his soldiers who were victorious in battle .
|
#' hsrr.
#'
#' @name hsrr
#' @docType package
#' @importFrom magrittr "%>%"
NULL
|
= = = County , state , and federal government = = =
|
The episode features mash @-@ up covers of " It 's My Life " by Bon Jovi and " Confessions Part II " by Usher , and " Halo " by Beyoncé Knowles and " Walking on Sunshine " by Katrina and the Waves . Both tracks were released as singles , available for digital download . " Vitamin D " was watched by 7 @.@ 30 million US viewers , and received generally positive reviews from critics . Performances by Morrison , Mays and Jane Lynch as cheerleading coach Sue Sylvester attracted praise , as did the staging of the musical mash @-@ ups . However , Aly Semigran of MTV and Mandi Bierly of Entertainment Weekly both noted critically that dramatic storylines in the episode dominated over the musical performances .
|
(* (c) Copyright Microsoft Corporation and Inria. All rights reserved. *)
Require Import ssreflect.
Require Import ssrbool.
Require Import funs.
Require Import dataset.
Require Import ssrnat.
Require Import znat.
Require Import frac.
Require Import real.
Require Import realsyntax.
Require Import Setoid.
Set Implicit Arguments.
Unset Strict Implicit.
Import Prenex Implicits.
Section RealOperations.
(**********************************************************)
(** Derived real operations: *)
(* definition by nondeterministic/deterministiccases, *)
(* min, max *)
(* injections from Z, and Q into R *)
(* floor, range1r (unit interval) *)
(**********************************************************)
Variable R : real_structure.
Open Scope real_scope.
Definition pickr_set P1 P2 (x1 x2 y : R) := P1 /\ y == x1 \/ P2 /\ y == x2.
Definition pickr P1 P2 x1 x2 := supr (pickr_set P1 P2 x1 x2).
Definition selr P := pickr P (~ P).
Definition minr x1 x2 := pickr (x1 <= x2) (x2 <= x1) x1 x2.
Definition maxr x1 x2 := pickr (x1 <= x2) (x2 <= x1) x2 x1.
Coercion Local natR := natr R.
Definition znatr m := match m with Zpos n => natr R n | Zneg n => - S n end.
Coercion Local znatr : znat >-> real_carrier.
Definition fracr f := let: Frac d m := f in m / S d.
Inductive floor_set (x : R) : R -> Prop :=
FloorSet : forall m : znat, m <= x -> floor_set x m.
Definition floor x := supr (floor_set x).
Definition range1r (x y : R) := x <= y < x + 1.
End RealOperations.
Notation "'select' { x1 'if' P1 , x2 'if' P2 }" := (pickr P1 P2 x1 x2)
(at level 10, x1, x2, P1, P2 at level 100,
format "'select' { x1 'if' P1 , x2 'if' P2 }") : real_scope.
Notation "'select' { x1 'if' P , 'else' x2 }" := (selr P x1 x2)
(at level 10, x1, x2, P at level 100,
format "'select' { x1 'if' P , 'else' x2 }") : real_scope.
Notation min := (@minr _).
Notation max := (@maxr _).
Section RealLemmas.
(* Basic arithmetic/order/setoid lemmas for real numbers. *)
(* The local definitions below need to be included verbatim *)
(* by clients of this module, along with all the setoid *)
(* declaration, in order to make setoid rewriting usable. *)
(* Note that the sup and inverse operators are not morphisms *)
(* because of the undefined cases. *)
(* Most of the lemmas here do not depend explicitly on *)
(* classical reasoning; to underscore this we only prove the *)
(* excluded middle at the very end of this section, when it *)
(* is needed to prove, e.g., the archimedean property. *)
Variable R : real_model.
Open Scope real_scope.
Let RR : Type := R.
Let isR (x : RR) := x.
Let eqR : RR -> RR -> Prop := @eqr _.
Let leqR : RR -> RR -> Prop := locked (@leqr _).
Let addR : RR -> RR -> RR := locked (@addr _).
Let oppR : RR -> RR := locked (@oppr _).
Let mulR : RR -> RR -> RR := locked (@mulr _).
Let selR : Prop -> RR -> RR -> RR := locked (@selr _).
Let minR : RR -> RR -> RR := locked (@minr _).
Let maxR : RR -> RR -> RR := locked (@maxr _).
Let floorR : RR -> RR := locked (@floor _).
Let range1R : RR -> RR -> Prop := @range1r _.
Coercion Local natR := natr R.
Coercion Local znatR := znatr R.
Coercion Local fracR := fracr R.
Remark rwR : forall x1 x2, x1 == x2 -> eqR (isR x1) (isR x2). Proof. done. Qed.
Remark leqRI : forall x1 x2, (x1 <= x2) = leqR (isR x1) (isR x2).
Proof. by unlock leqR. Qed.
Remark eqRI : forall x1 x2, (x1 == x2) = eqR (isR x1) (isR x2).
Proof. by unlock eqR. Qed.
Remark addRI : forall x1 x2, (x1 + x2)%R = addR (isR x1) (isR x2).
Proof. by unlock addR. Qed.
Remark oppRI : forall x, - x = oppR (isR x).
Proof. by unlock oppR. Qed.
Remark mulRI : forall x1 x2, x1 * x2 = mulR (isR x1) (isR x2).
Proof. by unlock mulR. Qed.
Remark selRI : forall P x1 x2,
select {x1 if P, else x2} = selR P (isR x1) (isR x2).
Proof. by unlock selR. Qed.
Remark minRI : forall x1 x2, min x1 x2 = minR (isR x1) (isR x2).
Proof. by unlock minR. Qed.
Remark maxRI : forall x1 x2, max x1 x2 = maxR (isR x1) (isR x2).
Proof. by unlock maxR. Qed.
Remark floorRI : forall x, floor x = floorR (isR x).
Proof. by unlock floorR. Qed.
Remark range1RI : forall x, range1r x = range1R (isR x).
Proof. by unlock range1R. Qed.
(*********************************************************)
(** Comparisons and the least upper bound axioms *)
(*********************************************************)
Lemma eqr_leq2 : forall x1 x2 : R, x1 == x2 <-> x1 <= x2 <= x1.
Proof. by split. Qed.
Lemma eqr_leq : forall x1 x2 : R, x1 == x2 -> x1 <= x2.
Proof. by move=> x1 x2 [Hx12 _]. Qed.
Lemma ltr_neq : forall x1 x2 : R, x1 < x2 -> x1 != x2.
Proof. rewrite /eqr; tauto. Qed.
Lemma gtr_neq : forall x1 x2 : R, x2 < x1 -> x1 != x2.
Proof. rewrite /eqr; tauto. Qed.
Lemma leqrr : forall x : R, x <= x.
Proof. exact (leqr_reflexivity R). Qed.
Hint Resolve leqrr.
Lemma leqr_trans : forall x1 x2 x3 : R, x1 <= x2 -> x2 <= x3 -> x1 <= x3.
Proof. exact (leqr_transitivity R). Qed.
Lemma ubr_sup : forall E : R -> Prop, hasr (ubr E) -> ubr E (sup E).
Proof.
by move=> E HhiE x Hx; apply: (supr_upper_bound R) (Hx); split; first by exists x.
Qed.
Lemma ubr_geq_sup : forall E (x : R), hasr (ubr E) -> sup E <= x -> ubr E x.
Proof. move=> E x; move/ubr_sup=> HhiE Hx y Hy; apply: leqr_trans Hx; auto. Qed.
Lemma supr_total : forall (x : R) E, has_supr E -> boundedr x E \/ sup E <= x.
Proof. exact (supr_totality R). Qed.
Lemma leqr_total : forall x1 x2 : R, x1 <= x2 \/ x2 <= x1.
Proof.
move=> x1 x2; pose E y := x2 = y.
have HE: (has_supr E) by split; exists x2; last by move=> x <-.
case: (supr_total x1 HE) => [[y <-]|HEx1]; first by left.
by right; apply: leqr_trans HEx1; apply: ubr_sup => //; exists x2; move=> x <-.
Qed.
Lemma ltr_total : forall x1 x2 : R, x1 != x2 -> x1 < x2 \/ x2 < x1.
Proof. move=> x1 x2; rewrite /eqr; move: (leqr_total x1 x2); tauto. Qed.
Lemma ltrW : forall x1 x2 : R, x1 < x2 -> x1 <= x2.
Proof. by move=> x1 x2 Hx12; case: (leqr_total x1 x2) => // *; case: Hx12. Qed.
Hint Resolve ltrW.
Lemma leqr_lt_trans : forall x1 x2 x3 : R, x1 <= x2 -> x2 < x3 -> x1 < x3.
Proof. move=> x1 x2 x3 Hx12 Hx23 Hx31; case: Hx23; exact: leqr_trans Hx12. Qed.
Lemma ltr_leq_trans : forall x1 x2 x3 : R, x1 < x2 -> x2 <= x3 -> x1 < x3.
Proof. move=> x1 x2 x3 Hx12 Hx23 Hx31; case: Hx12; exact: leqr_trans Hx31. Qed.
Lemma ltr_trans : forall x1 x2 x3 : R, x1 < x2 -> x2 < x3 -> x1 < x3.
Proof. move=> x1 x2 x3 Hx12; apply: leqr_lt_trans; exact: ltrW. Qed.
(**********************************************************)
(** The setoid structure *)
(**********************************************************)
Lemma eqr_refl : forall x : R, x == x.
Proof. split; apply: leqrr. Qed.
Hint Resolve eqr_refl.
Hint Unfold eqR.
Remark eqR_refl : forall x : R, eqR x x. Proof. auto. Qed.
Hint Resolve eqR_refl.
Lemma eqr_sym : forall x1 x2 : R, x1 == x2 -> x2 == x1.
Proof. rewrite /eqr; tauto. Qed.
Hint Immediate eqr_sym.
Lemma eqr_trans : forall x1 x2 x3 : R, x1 == x2 -> x2 == x3 -> x1 == x3.
Proof.
move=> x1 x2 x3 [Hx12 Hx21] [Hx23 Hx32]; split; eapply leqr_trans; eauto.
Qed.
Lemma eqr_theory : Setoid_Theory RR eqR.
Proof. split; auto; exact eqr_trans. Qed.
Add Setoid RR eqR eqr_theory.
Add Morphism isR : isr_morphism. Proof. done. Qed.
Add Morphism (@leqr _ : RR -> RR -> Prop) : leqr_morphism.
Proof. move: leqr_trans => Htr x1 y1 x2 y2 [_ Hyx1] [Hxy2 _]; eauto. Qed.
Add Morphism leqR : leqR_morphism.
Proof. unlock leqR; exact leqr_morphism. Qed.
(**********************************************************)
(** Addition *)
(**********************************************************)
Lemma addrC : forall x1 x2 : R, x1 + x2 == x2 + x1.
Proof. exact (addr_commutativity R). Qed.
Add Morphism (@addr _ : RR -> RR -> RR) : addr_morphism.
Proof.
move=> x1 y1 x2 y2 Dx1 Dx2; apply eqr_trans with (x1 + y2).
by case Dx2; split; apply: (addr_monotony R).
rewrite eqRI (rwR (addrC x1 y2)) (rwR (addrC y1 y2)).
by case Dx1; split; apply: (addr_monotony R).
Qed.
Add Morphism addR : addR_morphism.
Proof. unlock addR; exact addr_morphism. Qed.
Lemma addrA : forall x1 x2 x3 : R, x1 + (x2 + x3) == x1 + x2 + x3.
Proof. exact (addr_associativity R). Qed.
Lemma addrCA : forall x1 x2 x3 : R, x1 + (x2 + x3) == x2 + (x1 + x3).
Proof.
move=> x1 x2 x3; rewrite eqRI (rwR (addrA x1 x2 x3)) (rwR (addrA x2 x1 x3)).
by rewrite addRI (rwR (addrC x1 x2)) -addRI.
Qed.
Lemma add0r : forall x : R, 0 + x == x.
Proof. exact (addr_neutral_left R). Qed.
Lemma addr0 : forall x : R, x + 0 == x.
Proof. move=> x; rewrite eqRI (rwR (addrC x 0)); exact: add0r. Qed.
Lemma subrr : forall x : R, x - x == 0.
Proof. exact (addr_inverse_right R). Qed.
Lemma addr_inv : forall x1 x2 : R, - x1 + (x1 + x2) == x2.
Proof.
move=> x1 x2; rewrite eqRI (rwR (addrCA (- x1) x1 x2)).
rewrite (rwR (addrA x1 (- x1) x2)) addRI (rwR (subrr x1)) -addRI; exact: add0r.
Qed.
Lemma addr_injl : forall x x1 x2 : R, x + x1 == x + x2 -> x1 == x2.
Proof.
move=> x x1 x2 Ex12; rewrite eqRI -(rwR (addr_inv x x1)) addRI (rwR Ex12) -addRI.
exact: addr_inv.
Qed.
Lemma addr_injr : forall x x1 x2 : R, x1 + x == x2 + x -> x1 == x2.
Proof.
move=> x x1 x2; rewrite eqRI (rwR (addrC x1 x)) (rwR (addrC x2 x)).
exact: addr_injl.
Qed.
Lemma oppr_opp : forall x : R, - - x == x.
Proof.
move=> x; apply addr_injr with (- x); rewrite eqRI (rwR (subrr x)).
rewrite (rwR (addrC (- - x) (- x))); exact: subrr.
Qed.
Lemma oppr_add : forall x1 x2 : R, - (x1 + x2) == - x1 - x2.
Proof.
move=> x1 x2; apply addr_injl with (x1 + x2); rewrite eqRI.
rewrite (rwR (addrCA (x1 + x2) (-x1) (-x2))) (rwR (subrr (x1 + x2))).
rewrite addRI -(rwR (addrA x1 x2 (-x2))) -addRI.
by rewrite (rwR (addr_inv x1 (x2 - x2))) (rwR (subrr x2)).
Qed.
Lemma oppr_sub : forall x1 x2 : R, - (x1 - x2) == x2 - x1.
Proof.
move=> x1 x2; rewrite eqRI (rwR (oppr_add x1 (- x2))) addRI (rwR (oppr_opp x2)).
rewrite -addRI; apply: addrC.
Qed.
Lemma leqr_add2l : forall x x1 x2 : R, x + x1 <= x + x2 <-> x1 <= x2.
Proof.
move=> x x1 x2; split; last exact: (addr_monotony R).
move=> Hx12; rewrite leqRI -(rwR (addr_inv x x1)) -(rwR (addr_inv x x2)) -leqRI.
exact: (addr_monotony R).
Qed.
Lemma leqr_add2r : forall x x1 x2 : R, x1 + x <= x2 + x <-> x1 <= x2.
Proof.
move=> x x1 x2; rewrite leqRI (rwR (addrC x1 x)) (rwR (addrC x2 x)) -leqRI.
exact: leqr_add2l.
Qed.
Lemma leqr_0sub : forall x1 x2 : R, x1 <= x2 <-> 0 <= x2 - x1.
Proof.
move=> x1 x2; rewrite -(leqr_add2r (- x1) x1 x2) leqRI (rwR (subrr x1)) -leqRI.
by split.
Qed.
Lemma leqr_sub0 : forall x1 x2 : R, x1 <= x2 <-> x1 - x2 <= 0.
Proof.
move=> x1 x2; rewrite -(leqr_add2r (- x2) x1 x2) leqRI (rwR (subrr x2)) -leqRI.
by split.
Qed.
Lemma leqr_opp2 : forall x1 x2 : R, - x1 <= - x2 <-> x2 <= x1.
Proof.
move=> x1 x2; rewrite (leqr_0sub (- x1) (- x2)) (leqr_0sub x2 x1).
rewrite leqRI addRI (rwR (oppr_opp x1)) -addRI (rwR (addrC (oppr x2) x1)) -leqRI.
by split.
Qed.
Lemma oppr_inj : forall x1 x2 : R, - x1 == - x2 -> x1 == x2.
Proof.
move=> x y; rewrite /eqR /eqr (leqr_opp2 x y) (leqr_opp2 y x); tauto.
Qed.
Add Morphism (@oppr _ : RR -> RR) : oppr_morphism.
Proof.
move=> x y; rewrite /eqR /eqr (leqr_opp2 x y) (leqr_opp2 y x); tauto.
Qed.
Add Morphism oppR : oppR_morphism.
Proof. unlock oppR; exact oppr_morphism. Qed.
Lemma oppr0 : - (0 : R) == 0.
Proof. by rewrite eqRI -(rwR (subrr 0)) (rwR (add0r (- 0))). Qed.
(**********************************************************)
(** Multiplication *)
(**********************************************************)
Lemma mulrC : forall x1 x2 : R, x1 * x2 == x2 * x1.
Proof. exact (mulr_commutativity R). Qed.
Lemma mulr_addr : forall x x1 x2 : R, x * (x1 + x2) == x * x1 + x * x2.
Proof. exact (mulr_addr_distributivity_right R). Qed.
Lemma mulr_addl : forall x x1 x2 : R, (x1 + x2) * x == x1 * x + x2 * x.
Proof.
move=> x x1 x2;
rewrite eqRI (rwR (mulrC (x1 + x2) x)) (rwR (mulr_addr x x1 x2)).
by rewrite addRI (rwR (mulrC x x1)) (rwR (mulrC x x2)) -addRI.
Qed.
Add Morphism (@mulr _ : RR -> RR -> RR) : mulr_morphism.
Proof.
have Hpos: forall x x1 x2 : R, 0 <= x -> x1 == x2 -> x * x1 == x * x2.
by move=> x x1 x2 Hx [Hx12 Hx21]; split; apply (mulr_monotony R).
have Hmull: forall x x1 x2 : R, x1 == x2 -> x * x1 == x * x2.
move=> x x1 x2 Dx1; case: (leqr_total 0 x) => Hx; auto.
have Hx': 0 <= - x by move: Hx; rewrite -(leqr_opp2 0 x) !leqRI (rwR oppr0).
apply addr_injr with (- x * x1).
rewrite eqRI -(rwR (mulr_addl x1 x (- x))) 2!addRI -addRI.
rewrite (rwR (Hpos _ _ _ Hx' Dx1)) -addRI -(rwR (mulr_addl x2 x (- x))).
apply: Hpos; last done; apply eqr_leq; apply eqr_sym; apply subrr.
rewrite /eqR; move=> x1 y1 x2 y2 Dx1 Dx2.
apply eqr_trans with (x1 * y2); auto.
rewrite eqRI (rwR (mulrC x1 y2)) (rwR (mulrC y1 y2)) -eqRI; auto.
Qed.
Add Morphism mulR : mulR_morphism. Proof. unlock mulR; exact mulr_morphism. Qed.
Lemma mulrA : forall x1 x2 x3 : R, x1 * (x2 * x3) == x1 * x2 * x3.
Proof. exact (mulr_associativity R). Qed.
Lemma mulrCA : forall x1 x2 x3 : R, x1 * (x2 * x3) == x2 * (x1 * x3).
Proof.
move=> x1 x2 x3; rewrite eqRI (rwR (mulrA x1 x2 x3)) (rwR (mulrA x2 x1 x3)).
by rewrite mulRI (rwR (mulrC x1 x2)) -mulRI.
Qed.
Lemma mul1r : forall x : R, 1 * x == x.
Proof. exact (mulr_neutral_left R). Qed.
Lemma mulr1 : forall x : R, x * 1 == x.
Proof. move=> x; rewrite eqRI (rwR (mulrC x 1)); exact: mul1r. Qed.
Lemma mul2r : forall x : R, 2 * x == x + x.
Proof.
by move=> x; rewrite eqRI (rwR (mulr_addl x 1 1)) !addRI (rwR (mul1r x)).
Qed.
Lemma mul0r : forall x : R, 0 * x == 0.
Proof.
move=> x; apply addr_injl with (1 * x); rewrite eqRI -(rwR (mulr_addl x 1 0)).
by rewrite (rwR (addr0 (1 * x))) !mulRI (rwR (addr0 1)).
Qed.
Lemma mulr0 : forall x : R, x * 0 == 0.
Proof. by move=> x; rewrite eqRI (rwR (mulrC x 0)); apply: mul0r. Qed.
Lemma mulr_oppr :
forall x1 x2 : R, x1 * - x2 == - (x1 * x2).
Proof.
move=> x1 x2; apply addr_injl with (x1 * x2).
rewrite eqRI -(rwR (mulr_addr x1 x2 (- x2))) (rwR (subrr (x1 * x2))).
rewrite mulRI (rwR (subrr x2)) -mulRI; exact: mulr0.
Qed.
Lemma mulr_oppl : forall x1 x2 : R, - x1 * x2 == - (x1 * x2).
Proof.
move=> x1 x2; rewrite eqRI (rwR (mulrC (- x1) x2)) (rwR (mulr_oppr x2 x1)).
by rewrite !oppRI (rwR (mulrC x2 x1)).
Qed.
Lemma mulr_opp : forall x : R, - 1 * x == - x.
Proof.
by move=> x; rewrite eqRI (rwR (mulr_oppl 1 x)) !oppRI (rwR (mul1r x)).
Qed.
Lemma mulr_opp1 : forall x : R, x * - 1 == - x.
Proof. move=> x; rewrite eqRI (rwR (mulrC x (- 1))); exact: mulr_opp. Qed.
(* Properties of 1 (finally!) *)
Lemma neqr10 : (1 : R) != 0.
Proof. exact (mulr_neutral_nonzero R). Qed.
Lemma ltr01 : (0 : R) < 1.
Proof.
case/ltr_total: neqr10 => // H H10; case: H; move: (H10).
rewrite -(leqr_opp2 0 1) -(leqr_opp2 1 0) !leqRI (rwR oppr0) -leqRI.
move=> Hn1; rewrite -(rwR (mulr1 (- 1))) -(rwR (mulr0 (- 1))) -leqRI.
exact: (mulr_monotony R).
Qed.
Hint Resolve ltr01.
Lemma ltrSr : forall x : R, x < x + 1.
Proof.
by move=> x; rewrite leqRI -(rwR (addr0 x)) -leqRI (leqr_add2l x 1 0).
Qed.
Implicit Arguments ltrSr [].
Lemma ltPrr : forall x : R, x - 1 < x.
Proof.
move=> x /=; rewrite -(leqr_opp2 (x - 1) x) leqRI (rwR (oppr_add x (- 1))).
rewrite addRI (rwR (oppr_opp 1)) -addRI -leqRI; exact: ltrSr.
Qed.
Implicit Arguments ltPrr [].
Lemma ltr02 : (0 : R) < 2.
Proof. exact (ltr_trans ltr01 (ltrSr _)). Qed.
Hint Resolve ltr02.
(* Division (well, mostly inverse) *)
Lemma divrr : forall x : R, x != 0 -> x / x == 1.
Proof. exact (mulr_inverse_right R). Qed.
Lemma leqr_pmul2l : forall x x1 x2 : R, x > 0 -> (x * x1 <= x * x2 <-> x1 <= x2).
Proof.
move=> x x1 x2 Hx; split; last by apply (mulr_monotony R); exact: ltrW.
move=> Hx12; rewrite leqRI -(rwR (mul1r x1)) -(rwR (mul1r x2)).
rewrite !mulRI -(rwR (divrr (gtr_neq Hx))) (rwR (mulrC x (/ x))) -!mulRI.
rewrite -(rwR (mulrA (/ x) x x1)) -(rwR (mulrA (/ x) x x2)) -leqRI.
apply: (mulr_monotony R) Hx12; apply ltrW; move=> Hix.
case ltr01; rewrite leqRI -(rwR (divrr (gtr_neq Hx))) -(rwR (mulr0 x)) -leqRI.
apply: (mulr_monotony R) Hix; exact: ltrW.
Qed.
Lemma leqr_pmul2r : forall x x1 x2 : R, x > 0 -> (x1 * x <= x2 * x <-> x1 <= x2).
Proof.
move=> x x1 x2 Hx; rewrite leqRI (rwR (mulrC x1 x)) (rwR (mulrC x2 x)) -leqRI.
exact: leqr_pmul2l Hx.
Qed.
Lemma pmulr_inv : forall x x1 : R, x > 0 -> / x * (x * x1) == x1.
Proof.
move=> x x1 Hx; rewrite eqRI (rwR (mulrCA (/ x) x x1)) (rwR (mulrA x (/ x) x1)).
rewrite mulRI (rwR (divrr (gtr_neq Hx))) -mulRI; apply: mul1r.
Qed.
Lemma posr_pmull : forall x1 x2 : R, x1 > 0 -> (x1 * x2 <= 0 <-> x2 <= 0).
Proof.
move=> x1 x2 Hx1; rewrite -(leqr_pmul2l x2 0 Hx1) 2!leqRI (rwR (mulr0 x1)); tauto.
Qed.
Lemma pmulr_injl : forall x x1 x2 : R, x > 0 -> x * x1 == x * x2 -> x1 == x2.
Proof.
move=> x x1 x2 Hx Ex12; rewrite eqRI -(rwR (pmulr_inv x1 Hx)) mulRI (rwR Ex12).
rewrite -mulRI; exact (pmulr_inv x2 Hx).
Qed.
Lemma pmulr_injr : forall x x1 x2 : R, x > 0 -> x1 * x == x2 * x -> x1 == x2.
Proof.
move=> x x1 x2 Hx; rewrite eqRI (rwR (mulrC x1 x)) (rwR (mulrC x2 x)).
by apply: pmulr_injl.
Qed.
Lemma mulr_injl : forall x x1 x2 : R, x != 0 -> x * x1 == x * x2 -> x1 == x2.
Proof.
move=> x x1 x2 Hx; case: (leqr_total (real0 _) x) => Hx0.
by apply: pmulr_injl => [H0x]; case Hx; split.
move/oppr_morphism; rewrite eqRI -(rwR (mulr_oppl x x1)) -(rwR (mulr_oppl x x2)).
apply: pmulr_injl; rewrite leqRI -(rwR oppr0) -leqRI (leqr_opp2 x 0).
by move=> H0x; case Hx; split.
Qed.
Lemma mulr_injr : forall x x1 x2 : R, x != 0 -> x1 * x == x2 * x -> x1 == x2.
Proof.
move=> x x1 x2 Hx; rewrite eqRI (rwR (mulrC x1 x)) (rwR (mulrC x2 x)).
exact: mulr_injl.
Qed.
(* The inverse is only a partial morphism. It might be worth fixing, say, *)
(* 1/0 = 0 in order to make setoid rewriting work better. *)
Lemma invr_morphism : forall x y : R, x != 0 -> x == y -> / x == / y.
Proof.
move=> x y Hx Dx; have Hy: y != 0 by rewrite eqRI -(rwR Dx).
apply: (mulr_injl Hx); rewrite eqRI (rwR (divrr Hx)) -(rwR (divrr Hy)).
by rewrite !mulRI (rwR Dx).
Qed.
Lemma invr1 : / (1 : R) == 1.
Proof. by rewrite eqRI -(rwR (divrr neqr10)) (rwR (mul1r (invr 1))). Qed.
Lemma invr_pmul : forall x1 x2 : R, x1 > 0 -> x2 > 0 ->
/ (x1 * x2) == / x1 * / x2.
Proof.
move=> x1 x2 Hx1 Hx2; set y := / (x1 * x2); apply: (pmulr_injl Hx1).
rewrite eqRI (rwR (mulrCA x1 (/ x1) (/ x2))) (rwR (pmulr_inv (/ x2) Hx1)) /isR.
apply: (pmulr_injl Hx2); rewrite eqRI (rwR (divrr (gtr_neq Hx2))).
rewrite (rwR (mulrCA x2 x1 y)) (rwR (mulrA x1 x2 y)).
apply: divrr; apply: gtr_neq; rewrite leqRI -(rwR (mulr0 x1)) -leqRI.
by rewrite (leqr_pmul2l x2 0 Hx1).
Qed.
Lemma invr_opp : forall x : R, x != 0 -> / - x == - / x.
Proof.
move=> x Hx; apply: (mulr_injl Hx); apply oppr_inj.
rewrite eqRI -(rwR (mulr_oppl x (/ - x))) -(rwR (mulr_oppr x (- / x))).
rewrite !mulRI (rwR (oppr_opp (/ x))) -!mulRI (rwR (divrr Hx)); apply: divrr.
by rewrite eqRI -(rwR oppr0) -eqRI; move/oppr_inj.
Qed.
Lemma posr_inv : forall x : R, x > 0 -> / x > 0.
Proof.
move=> x Hx; rewrite -(leqr_pmul2l (/ x) 0 Hx).
by rewrite leqRI (rwR (mulr0 x)) (rwR (divrr (gtr_neq Hx))) -leqRI.
Qed.
Lemma leqr_pinv2 : forall x1 x2 : R, x1 > 0 -> x2 > 0 ->
( / x1 <= / x2 <-> x2 <= x1).
Proof.
move=> x1 x2 Hx1 Hx2; rewrite -(leqr_pmul2r (/ x1) (/ x2) Hx1).
rewrite -(leqr_pmul2l (/ x1 * x1) (/ x2 * x1) Hx2).
rewrite !leqRI (rwR (mulrC x2 (/ x1 * x1))) -(rwR (mulrA (/ x1) x1 x2)).
rewrite (rwR (mulrCA x2 (/ x2) x1)) (rwR (pmulr_inv x1 Hx2)).
rewrite (rwR (pmulr_inv x2 Hx1)); tauto.
Qed.
(**********************************************************)
(** The least upper bound and derived operations. *)
(**********************************************************)
Lemma leqr_sup_ub : forall E (x : R), hasr E -> ubr E x -> sup E <= x.
Proof.
move=> E x HloE Hx; set y := sup E; pose z := (x + y) / 2.
have Dz: 2 * z == x + y.
apply: (eqr_trans (mulrA _ _ _)); apply: (eqr_trans (mulrC _ _)).
apply: pmulr_inv; exact ltr02.
have HE: has_supr E by split; last by exists x.
case: (supr_total z HE) => [[t Ht Hzt]|Hyz].
rewrite -(leqr_add2l x y x) leqRI -(rwR Dz) -(rwR (mul2r x)) -leqRI.
rewrite (leqr_pmul2l z x ltr02); apply: (leqr_trans Hzt); auto.
rewrite -(leqr_add2r y y x) leqRI -(rwR Dz) -(rwR (mul2r y)) -leqRI.
by rewrite (leqr_pmul2l y z ltr02).
Qed.
Lemma supr_sup : forall E, has_supr E -> forall x : R, ubr E x <-> sup E <= x.
Proof.
by move=> E [HloE HhiE] x; split; [ apply leqr_sup_ub | apply ubr_geq_sup ].
Qed.
(* Partial morphism property of the sup function; similarly to 1/0, *)
(* it might be helpful to define (supr [_]True) and (supr [_]False). *)
Lemma supr_morphism : forall E, has_supr E -> forall E',
(forall x : R, E x <-> E' x) -> sup E == sup E'.
Proof.
have Hleq: forall E E', hasr E -> hasr (ubr E') ->
(forall x : R, E x -> E' x) -> sup E <= sup E'.
by move=> *; apply: leqr_sup_ub => // x Hx; apply ubr_sup; auto.
move=> E [HloE HhiE] E' DE'.
split; (apply Hleq; auto; last by move=> x; case (DE' x); auto).
by move: HhiE => [y Hy]; exists y; move=> x; case (DE' x); auto.
by move: HloE => [x Hx]; case (DE' x); exists x; auto.
Qed.
(* Definition by nondeterministic cases. *)
Section PickrCases.
Variables (P1 P2 : Prop) (x1 x2 : R).
Hypotheses (HP : P1 \/ P2) (HPx : P1 /\ P2 -> x1 == x2).
Inductive pickr_spec : R -> Prop :=
PickrSpec : forall y, pickr_set P1 P2 x1 x2 y -> pickr_spec y.
Lemma pickr_cases : pickr_spec (select {x1 if P1, x2 if P2}).
Proof.
pose ps := pickr_set P1 P2 x1 x2; set x := select {x1 if P1, x2 if P2}.
have [x3 Hx3lo Ex3]: exists2 x3, ps x3 & forall y, ps y <-> y == x3.
case: HP => HPi; [ exists x1; try split; try by left; split
| exists x2; try split; try by right; split ];
case; case=> Hpj Dy //; apply: (eqr_trans Dy); auto; apply eqr_sym; auto.
have Hx3hi: ubr ps x3.
by move=> x4; rewrite (Ex3 x4); move=> Dx4; rewrite leqRI (rwR Dx4) -leqRI.
split; rewrite -/ps (Ex3 x); split; last by apply: ubr_sup; first by exists x3.
by apply: leqr_sup_ub; first by exists x3.
Qed.
End PickrCases.
Section PickrMorphism.
Variables (P1 P2 : Prop) (x1 x2 : R).
Hypotheses (HP : P1 \/ P2) (HPx : P1 /\ P2 -> x1 == x2).
Lemma pickr_morphism : forall Q1 Q2 y1 y2,
(P1 <-> Q1) -> (P2 <-> Q2) -> x1 == y1 -> x2 == y2 ->
select {x1 if P1, x2 if P2} == select {y1 if Q1, y2 if Q2}.
Proof.
move=> Q1 Q2 y1 y2 DP1 DP2 Dx1 Dx2; rewrite -/eqR.
have HQ: Q1 \/ Q2 by rewrite -DP1 -DP2.
have HQy: Q1 /\ Q2 -> y1 == y2 by rewrite -DP1 -DP2 eqRI -(rwR Dx1) -(rwR Dx2).
case: (pickr_cases HQ HQy) => y; case: (pickr_cases HP HPx) => x.
rewrite /pickr_set -DP1 -DP2 (eqRI y y1) -(rwR Dx1) (eqRI y y2) -(rwR Dx2) -!eqRI.
case; case=> HPi Dx; case; case=> HPj Dy;
rewrite /eqR eqRI (rwR Dx) (rwR Dy) -eqRI; auto; apply eqr_sym; auto.
Qed.
End PickrMorphism.
(* min and max. *)
Section MinMaxReal.
Variable x1 x2 : R.
Let Hx12 := leqr_total x1 x2.
Let Ex12 (H : x1 <= x2 <= x1) := H : x1 == x2.
Let Ex21 (H : x1 <= x2 <=x1) := eqr_sym H.
Lemma leqr_minl : min x1 x2 <= x1.
Proof.
rewrite /minr; case: (pickr_cases Hx12 Ex12) => x3.
by case; case=> Hx Dx3; rewrite leqRI (rwR Dx3) -leqRI.
Qed.
Lemma leqr_minr : min x1 x2 <= x2.
Proof.
rewrite /minr; case: (pickr_cases Hx12 Ex12) => x3.
by case; case=> Hx Dx3; rewrite leqRI (rwR Dx3) -leqRI.
Qed.
Hint Resolve leqr_minl leqr_minr.
Lemma ltr_min : forall x : R, x < min x1 x2 <-> x < x1 /\ x < x2.
Proof.
rewrite /minr; case: (pickr_cases Hx12 Ex12) => x3.
case; case=> Hx Dx3 x; rewrite leqRI (rwR Dx3) -leqRI;
by split; [ split; try exact: ltr_leq_trans Hx | case ].
Qed.
Lemma leqr_min : forall x : R, x <= min x1 x2 <-> x <= x1 /\ x <= x2.
Proof.
move=> x; split; first by split; eapply leqr_trans; eauto.
move=> [Hxx1 Hxx2]; rewrite /minr; case: (pickr_cases Hx12 Ex12) => x3.
by case; case=> Hx Dx3; rewrite leqRI (rwR Dx3) -leqRI.
Qed.
Lemma leqr_maxl : x1 <= max x1 x2.
Proof.
rewrite /maxr; case: (pickr_cases Hx12 Ex21) => x3.
by case; case=> Hx Dx3; rewrite leqRI (rwR Dx3) -leqRI.
Qed.
Lemma leqr_maxr : x2 <= max x1 x2.
Proof.
rewrite /maxr; case: (pickr_cases Hx12 Ex21) => x3.
by case; case=> Hx Dx3; rewrite leqRI (rwR Dx3) -leqRI.
Qed.
Hint Resolve leqr_maxl leqr_maxr.
Lemma ltr_max : forall x : R, max x1 x2 < x <-> x1 < x /\ x2 < x.
Proof.
rewrite /maxr; case: (pickr_cases Hx12 Ex21) => x3.
case; case=> Hx Dx3 x; rewrite leqRI (rwR Dx3) -leqRI;
by split; [ split; try exact: (leqr_lt_trans Hx) | case ].
Qed.
Lemma leqr_max : forall x : R, maxr x1 x2 <= x <-> x1 <= x /\ x2 <= x.
Proof.
move=> x; split; first by split; eapply leqr_trans; eauto.
move=> [Hxx1 Hxx2]; rewrite /maxr; case: (pickr_cases Hx12 Ex21) => x3.
by case; case=> Hx Dx3; rewrite leqRI (rwR Dx3) -leqRI.
Qed.
End MinMaxReal.
Add Morphism (minr (R := _) : RR -> RR -> RR) : minr_morphism.
Proof.
move=> x1 y1 x2 y2 Dx1 Dx2; apply: (pickr_morphism _ _ _) => //;
try apply leqr_total; by rewrite !leqRI Dx1 Dx2; split.
Qed.
Add Morphism minR : minR_morphism. Proof. unlock minR; exact minr_morphism. Qed.
Add Morphism (maxr (R := _) : RR -> RR -> RR) : maxr_morphism.
Proof.
move=> x1 y1 x2 y2 Dx1 Dx2; apply: (pickr_morphism _ _ _) => //;
try apply leqr_total; try by rewrite !leqRI Dx1 Dx2; split.
by move/eqr_sym.
Qed.
Add Morphism maxR : maxR_morphism. Proof. unlock maxR; exact maxr_morphism. Qed.
(**********************************************************)
(** Properties of the injections from N, Z, and Q into R *)
(**********************************************************)
Lemma natr_S : forall n, S n == n + 1.
Proof.
case=> [|n] /=; first by rewrite eqRI (rwR (add0r 1)).
elim: n {2 3}(real1 R) => //= [] x; apply addrC.
Qed.
Lemma ltr0Sn : forall n, 0 < S n.
Proof.
elim=> // n Hrec; apply: ltr_trans Hrec _.
rewrite leqRI -(rwR (addr0 (S n))) (rwR (natr_S (S n))) -leqRI.
by rewrite (leqr_add2l (S n) 1 0).
Qed.
Implicit Arguments ltr0Sn [].
Lemma leqr0n : forall n : nat, 0 <= n.
Proof. by move=> [|n]; [ apply leqrr | apply ltrW; apply ltr0Sn ]. Qed.
Lemma znatr_inc : forall m, incz m == m + 1.
Proof.
move=> [n|n]; rewrite eqRI; first by rewrite /= -/natR -(rwR (natr_S n)).
case: n => [|n]; first by rewrite /= (rwR (addrC (- 1) 1)) (rwR (subrr 1)).
rewrite {2}/znatR /znatr -/natR addRI oppRI (rwR (natr_S (S n))) -oppRI.
rewrite (rwR (oppr_add (S n) 1)) -addRI.
rewrite -(rwR (addrA (- S n) (- 1) 1)) addRI (rwR (addrC (- 1) 1)).
by rewrite (rwR (subrr 1)) -addRI (rwR (addr0 (- (S n)))).
Qed.
Lemma znatr_dec : forall m, decz m == m - 1.
Proof.
move=> m; rewrite -{2}[m]incz_dec; move/decz: m => m.
rewrite eqRI addRI (rwR (znatr_inc m)) -addRI -(rwR (addrA m 1 (- 1))).
by rewrite addRI (rwR (subrr 1)) -addRI (rwR (addr0 m)).
Qed.
Lemma znatr_opp : forall m, (- m)%Z == - m.
Proof.
move=> [[|[|n]]|[|m]] //=; apply eqr_sym; first [ exact: oppr0 | exact: oppr_opp ].
Qed.
Lemma znatr_add : forall m1 m2, (m1 + m2)%Z == m1 + m2.
Proof.
have znatr_addpos: forall (n : nat) m, (n + m)%Z == n + m.
move=> n m; elim: n => [|n Hrec]; first by rewrite add0z /= eqRI (rwR (add0r m)).
rewrite eqRI addRI (rwR (natr_S n)) -addRI -add1n zpos_addn -addzA addzC.
rewrite -incz_def (rwR (znatr_inc (n + m))) addRI (rwR Hrec) -addRI.
rewrite -(rwR (addrA n m 1)) -(rwR (addrA n 1 m)).
by rewrite addRI (rwR (addrC m 1)) -addRI.
move=> [n1|m1] m2; first by apply: znatr_addpos.
set m12 := (_ + _)%Z; rewrite -(oppz_opp m12) eqRI.
rewrite (rwR (znatr_opp (- m12))) {}/m12 oppz_add [addz]lock /= -lock.
rewrite oppRI (rwR (znatr_addpos (S m1) (- m2)%Z)) -oppRI.
rewrite (rwR (oppr_add (S m1) (- m2)%Z)) addRI.
by rewrite -(rwR (znatr_opp (- m2))) oppz_opp -addRI.
Qed.
Lemma znatr_subz : forall m1 m2, (m1 - m2)%Z == m1 - m2.
Proof.
move=> m1 m2; rewrite eqRI (rwR (znatr_add m1 (- m2))).
by rewrite !addRI (rwR (znatr_opp m2)).
Qed.
Lemma znatr_mul : forall m1 m2, (m1 * m2)%Z == m1 * m2.
Proof.
move=> m1 m2; elim/oppz_cases: m1 => [m1 Dm12|n1].
rewrite mulz_oppl eqRI (rwR (znatr_opp (m1 * m2))) oppRI {Dm12}(rwR Dm12).
by rewrite -oppRI -(rwR (mulr_oppl m1 m2)) !mulRI (rwR (znatr_opp m1)).
elim: n1 => [|n1 Hrec]; first by rewrite mul0z eqRI /= (rwR (mul0r m2)).
rewrite -add1n zpos_addn mulzC mulz_addr !(mulzC m2) eqRI [(_ * _)%Z]/= mulRI.
rewrite (rwR (znatr_add (Zpos 1%nat) n1)) (rwR (znatr_add m2 (n1 * m2)%Z)) -mulRI.
rewrite addRI (rwR Hrec) /= -/natR (rwR (mulr_addl m2 1 n1)) addRI.
by rewrite (rwR (mul1r m2)).
Qed.
Lemma znatr_scale : forall d m, scalez d m == S d * m.
Proof. move=> d m; exact (znatr_mul (S d) m). Qed.
Lemma znatr_addbit : forall m : znat, m == oddz m + 2 * halfz m.
Proof.
move=> m; rewrite -{1}[m]odd_double_halfz; move/halfz: m (oddz m) => m b.
rewrite eqRI (rwR (znatr_add b (m + m))) 2!addRI (rwR (mul2r m)).
by rewrite (rwR (znatr_add m m)).
Qed.
Lemma znatr_leqPx : forall m1 m2 : znat, reflect (m1 <= m2) (m1 <= m2)%Z.
Proof.
move=> m1 m2; rewrite /leqz; apply: (iffP idP);
rewrite (leqr_sub0 m1 m2) leqRI -(rwR (znatr_subz m1 m2)) -leqRI;
case: (m1 - m2)%Z => [[|n]|m] //; last by case/ltr0Sn.
rewrite leqRI -(rwR oppr0) -leqRI /znatR /znatr -/natR (leqr_opp2 (S m) 0).
clear; exact: leqr0n.
Qed.
Notation znatr_leqP := (znatr_leqPx _ _).
Lemma znatr_ltPx : forall m1 m2 : znat, reflect (m1 < m2) (incz m1 <= m2)%Z.
Proof.
move=> m1 m2; rewrite -negb_leqz.
by apply: (iffP idP) => Hm12; [ move/znatr_leqP: Hm12 | apply/znatr_leqP ].
Qed.
Notation znatr_ltP := (znatr_ltPx _ _).
(* Embedding the rationals. *)
Lemma fracr_eq : forall d m f, f = Frac d m -> m == S d * f.
Proof.
move=> d m f Df; rewrite Df /fracR /fracr -/natR -/znatR eqRI.
rewrite (rwR (mulrA (S d) m (/ S d))) (rwR (mulrC (S d * m) (/ S d))).
by rewrite (rwR (pmulr_inv m (ltr0Sn d))).
Qed.
Lemma fracr_leqPx : forall f1 f2 : frac, reflect (f1 <= f2) (leqf f1 f2).
Proof.
move=> f1 f2; case Df1: {2}f1 => [d1 m1]; case Df2: {2}f2 => [d2 m2] /=.
suffice [Hzr Hrz]: scalez d2 m1 <= scalez d1 m2 <-> f1 <= f2.
exact: (iffP (znatr_leqPx _ _)).
rewrite leqRI (rwR (znatr_scale d2 m1)) (rwR (znatr_scale d1 m2)).
rewrite !mulRI (rwR (fracr_eq Df1)) (rwR (fracr_eq Df2)) -!mulRI.
rewrite (rwR (mulrCA (S d2) (S d1) f1)) -leqRI.
rewrite (leqr_pmul2l (S d2 * f1) (S d2 * f2) (ltr0Sn d1)).
apply: leqr_pmul2l; exact: ltr0Sn.
Qed.
Notation fracr_leqP := (fracr_leqPx _ _).
Lemma fracr_ltPx : forall f1 f2 : frac, reflect (f1 < f2) (ltf f1 f2).
Proof.
move=> f1 f2; rewrite /ltf; case (fracr_leqPx f2 f1); constructor; tauto.
Qed.
Notation fracr_ltP := (fracr_ltPx _ _).
Lemma fracrz : forall m, let f := Frac 0%nat m in m == f.
Proof. move=> m f; rewrite eqRI -(rwR (mul1r f)); exact: (@fracr_eq 0%nat). Qed.
Lemma fracr0 : F0 == 0.
Proof. apply eqr_sym; exact (fracrz 0%nat). Qed.
Lemma fracr1 : F1 == 1.
Proof. apply eqr_sym; exact (fracrz 1%nat). Qed.
Lemma fracr2 : F2 == 2.
Proof. apply eqr_sym; exact (fracrz 2%nat). Qed.
Lemma fracr_posPx : forall f : frac, reflect (f <= 0) (negb (posf f)).
Proof.
move=> f; rewrite -nposfI.
by apply: (iffP (fracr_leqPx _ _)); rewrite !leqRI (rwR fracr0).
Qed.
Notation fracr_posP := (fracr_posPx _).
Lemma fracr_opp : forall f, oppf f == - f.
Proof.
move=> [d m]; rewrite /oppf /fracR /fracr -/znatR -/natR eqRI.
rewrite !mulRI (rwR (znatr_opp m)) -!mulRI; apply: mulr_oppl.
Qed.
Lemma natr_muld : forall d1 d2 : nat, S (muld d1 d2) == S d1 * S d2.
Proof.
move=> d1 d2; apply: eqr_trans (znatr_mul (S d1) (S d2)).
by rewrite muldE mulz_nat.
Qed.
Lemma fracr_add : forall f1 f2, addf f1 f2 == f1 + f2.
Proof.
move=> f1 f2; move Df: (addf f1 f2) => f.
case Df1: {1}f1 Df => [d1 m1]; case Df2: {1}f2 => [d2 m2] /=.
set d := muld d1 d2; move/esym=> Df; apply: (pmulr_injl (ltr0Sn d)).
rewrite eqRI (rwR (mulr_addr (S d) f1 f2)) -{Df}(rwR (fracr_eq Df)).
rewrite (rwR (znatr_add (scalez d2 m1) (scalez d1 m2))) !addRI.
rewrite (rwR (znatr_scale d2 m1)) (rwR (znatr_scale d1 m2)) !mulRI {}/d.
rewrite (rwR (fracr_eq Df1)) (rwR (fracr_eq Df2)) (rwR (natr_muld d1 d2)) -!mulRI.
rewrite (rwR (mulrCA (S d2) (S d1) f1)).
by rewrite (rwR (mulrA (S d1) (S d2) f1)) (rwR (mulrA (S d1) (S d2) f2)).
Qed.
Lemma fracr_mul : forall f1 f2, mulf f1 f2 == f1 * f2.
Proof.
move=> f1 f2; move Df: (mulf f1 f2) => f.
case Df1: {1}f1 Df => [d1 m1]; case Df2: {1}f2 => [d2 m2] /=.
set d := muld d1 d2; move/esym=> Df; apply: (pmulr_injl (ltr0Sn d)).
rewrite eqRI -(rwR (fracr_eq Df)) (rwR (znatr_mul m1 m2)).
rewrite mulRI (rwR (fracr_eq Df1)) (rwR (fracr_eq Df2)) -mulRI.
rewrite -(rwR (mulrA (S d1) f1 (S d2 * f2))).
rewrite mulRI (rwR (mulrCA f1 (S d2) f2)) -mulRI.
rewrite (rwR (mulrA (S d1) (S d2) (f1 * f2))).
by rewrite mulRI -(rwR (natr_muld d1 d2)) -/d -mulRI.
Qed.
Lemma fracr_pinv : forall f, posf f -> invf f == / f.
Proof.
move=> f Hff; have Hf: 0 < f.
move: Hff; rewrite -posfI; move/fracr_leqP.
by rewrite leqRI /F0 -(rwR (fracrz 0%nat)) -leqRI.
apply: (pmulr_injl Hf); rewrite eqRI (rwR (divrr (gtr_neq Hf))).
case Df: {1 3}f Hff => [d [[|m]|m]] // _; rewrite /invf {2}/fracR /fracr /znatr.
rewrite -/natR (rwR (mulrA f (S d) (/ S m))) mulRI (rwR (mulrC f (S d))).
rewrite -(rwR (fracr_eq Df)) -mulRI; apply: divrr; apply gtr_neq; exact: ltr0Sn.
Qed.
(* The floor function *)
Remark ubr_floor_set : forall x : R, ubr (floor_set x) x.
Proof. by move=> x y [m]. Qed.
Hint Resolve ubr_floor_set.
Remark hasr_ub_floor_set : forall x : R, hasr (ubr (floor_set x)).
Proof. by move=> x; exists x. Qed.
Hint Resolve hasr_ub_floor_set.
Remark hasr_floor_max : forall x : R, hasr (floor_set x) -> x < floor x + 1.
Proof.
move=> x Hxlo Hx; have Hinc: forall m : znat, m <= x -> incz m <= x.
move=> m Hm; apply: leqr_trans Hx; rewrite leqRI (rwR (znatr_inc m)) -leqRI.
rewrite (leqr_add2r 1 m (floor x)); apply: ubr_sup; auto.
by rewrite /znatR; split.
have Hsup: has_supr (floor_set x) by split.
case: (supr_total (floor x - 1) Hsup); last exact: ltPrr.
move=> [_ [m]]; do 2 move/Hinc.
rewrite -/znatR -{2}[m]decz_inc; move/incz: m => m Hm.
rewrite leqRI (rwR (znatr_dec m)) -!leqRI (leqr_add2r (- 1) (floor x) m).
move=> H; case: {H}(leqr_lt_trans H (ltrSr _)).
by rewrite leqRI -(rwR (znatr_inc m)) -leqRI /znatR; apply: ubr_sup; auto; split.
Qed.
Remark hasr_lb_floor_set : forall x : R, hasr (floor_set x).
Proof.
move=> x; case: (leqr_total 0 x) => Hx; first by exists (znatr R 0%nat); split.
have Hnx: has_supr (floor_set (- x)).
split; auto; exists (znatr R 0%nat); split.
by rewrite leqRI /= -(rwR oppr0) -leqRI (leqr_opp2 0 x).
case: (supr_total (floor (- x) - 1) Hnx); last by case/ltPrr.
case; auto; move=> _ [m _] Hm; set m1 := incz m; set m2 := incz m1.
exists (znatr R (- m2)); split; move: Hm.
rewrite -/znatR !leqRI -[m]decz_inc -/m1 (rwR (znatr_dec m1)).
rewrite (rwR (znatr_opp m2)) -(rwR (oppr_opp x)) -!leqRI.
rewrite (leqr_add2r (- 1) (floor (- x)) m1) (leqr_opp2 m2 (- x)).
rewrite -(leqr_add2r 1 (floor (- x)) m1) leqRI -(rwR (znatr_inc m1)) -leqRI.
by apply: leqr_trans; apply ltrW; apply hasr_floor_max; case Hnx.
Qed.
Hint Resolve hasr_lb_floor_set.
Lemma has_supr_floor_set : forall x : R, has_supr (floor_set x).
Proof. by split. Qed.
Hint Resolve has_supr_floor_set.
Add Morphism (@floor _ : RR -> RR) : floor_morphism.
Proof.
move=> x x' Dx; apply: supr_morphism; first by split.
by move=> y; split; case=> m Hm {y}; split; apply: (leqr_trans Hm); case Dx.
Qed.
Add Morphism floorR : floorR_morphism.
Proof. unlock floorR; exact floor_morphism. Qed.
Add Morphism range1R : range1r_morphism.
Proof.
move=> x1 y1 x2 y2 Dx1 Dx2.
by rewrite /range1R /range1r !leqRI !addRI (rwR Dx1) (rwR Dx2).
Qed.
Lemma range1r_floor : forall x : R, range1r (floor x) x.
Proof. by move=> x; split; [ apply: leqr_sup_ub | apply hasr_floor_max ]. Qed.
Lemma znat_floor : forall x : R, exists m : znat, floor x == m.
Proof.
move=> x; case: (range1r_floor x); set y := floor x => Hyx Hxy; pose h2 : R := / 2.
have Hh2: 0 < h2 by exact: posr_inv.
have Hyh2: y - h2 < y.
rewrite (leqr_0sub y (y - h2)) leqRI (rwR (addrC (y - h2) (- y))).
by rewrite (rwR (addr_inv y (- h2))) -(rwR oppr0) -leqRI (leqr_opp2 0 h2).
case: (supr_total (y - h2) (has_supr_floor_set x)) => Hy2; last by case: Hyh2.
case: Hy2 => [_ [m Hmx] Hym]; rewrite -/znatR in Hmx Hym; exists m.
split; last by apply: ubr_sup; auto; rewrite /znatR; split.
apply: leqr_sup_ub; auto => _ [m' Hm'].
apply: znatr_leqP; rewrite -leqz_inc2; apply/znatr_ltP; set m1 := m + h2.
have Hym1: y <= m1.
rewrite -(leqr_add2r (- h2) y m1); apply: (leqr_trans Hym); apply eqr_leq.
rewrite eqRI /m1 addRI (rwR (addrC m h2)) -addRI.
by rewrite (rwR (addrC (h2 + m) (- h2))) (rwR (addr_inv h2 m)).
move: (Hh2); rewrite -(leqr_add2l m1 h2 0) leqRI (rwR (addr0 m1)).
rewrite {1}/m1 -(rwR (addrA m h2 h2)) addRI -(rwR (mul2r h2)) /h2.
rewrite (rwR (divrr (gtr_neq ltr02))) -addRI -(rwR (znatr_inc m)) -leqRI.
by apply: leqr_lt_trans; apply: (ubr_geq_sup _ Hym1) => //; rewrite /znatR; split.
Qed.
Lemma range1z_inj : forall (x : R) (m1 m2 : znat),
range1r m1 x -> range1r m2 x -> m1 = m2.
Proof.
move=> x.
suffice: forall m1 m2 : znat, range1r m1 x -> range1r m2 x -> (m1 <= m2)%Z.
by move=> Hle m1 m2 Hm1 Hm2; apply: eqP; rewrite eqz_leq !Hle.
move=> m1 m2 [Hm1 _] [_ Hm2]; rewrite -leqz_inc2; apply/znatr_ltP.
rewrite leqRI (rwR (znatr_inc m2)) -leqRI; eapply leqr_lt_trans; eauto.
Qed.
Lemma range1zz : forall m : znat, range1r m m.
Proof.
move=> m; split; auto; rewrite leqRI -(rwR (znatr_inc m)) -leqRI.
apply: znatr_ltP; exact: leqzz.
Qed.
Lemma range1z_floor : forall (m : znat) (x : R), range1r m x <-> floor x == m.
Proof.
have Hlr: forall (m : znat) (x : R), floor x == m -> range1r m x.
move=> m x Dm; rewrite range1RI -(rwR Dm); exact: range1r_floor.
move=> m x; split; auto; case: (znat_floor x) => [m' Dm'] Hm.
by rewrite -(range1z_inj (Hlr _ _ Dm') Hm).
Qed.
Lemma floor_znat : forall m : znat, floor m == m.
Proof. move=> m; rewrite -(range1z_floor m m); exact: range1zz. Qed.
Lemma find_range1z : forall x : R, exists m : znat, range1r m x.
Proof.
move=> x; case: (znat_floor x) => [m Hm]; exists m; case (range1z_floor m x); auto.
Qed.
Lemma fracr_dense : forall x y : R, x < y -> exists2 f : frac, x < f & f < y.
Proof.
move=> x y Hxy; pose z := y - x.
have Hz: z > 0 by rewrite leqRI -(rwR (subrr x)) -leqRI /z (leqr_add2r (- x) y x).
case: (find_range1z (invr z)) => [[d|m] [Hdz Hzd]].
set dd : R := S d; have Hdd: dd > 0 by exact: ltr0Sn.
case: (find_range1z (dd * x)) => [m [Hmx Hxm]].
move Df': (Frac d (incz m)) => f'; move/esym: Df' => Df'; exists f'.
- rewrite -(leqr_pmul2l f' x Hdd) {1}/dd leqRI -(rwR (fracr_eq Df')).
by rewrite (rwR (znatr_inc m)) -leqRI.
- rewrite -(leqr_pmul2l y f' Hdd) {2}/dd leqRI -(rwR (fracr_eq Df')).
rewrite mulRI -(rwR (addr_inv x y)) (rwR (addrC (- x) (x + y))).
rewrite -(rwR (addrA x y (- x))) -/z -mulRI (rwR (znatr_inc m)).
rewrite (rwR (mulr_addr dd x z)) -leqRI; move: Hmx.
rewrite -(leqr_add2r (dd * z) m (dd * x)); apply: ltr_leq_trans.
rewrite (leqr_add2l m (dd * z) 1).
rewrite leqRI -(rwR (divrr (gtr_neq Hz))) (rwR (mulrC dd z)) -leqRI.
by rewrite (leqr_pmul2l (dd : RR) (invr z) Hz) leqRI /dd (rwR (natr_S d)) -leqRI.
case Hzd; apply ltrW; apply: leqr_lt_trans (posr_inv Hz).
rewrite leqRI -(rwR (znatr_inc (Zneg m))) -leqRI.
by apply: (znatr_leqPx _ 0%nat); case m.
Qed.
(**********************************************************)
(* The excluded middle, and lemmas that depend on *)
(* explicit classical reasoning. *)
(**********************************************************)
Lemma reals_classic : excluded_middle.
Proof.
move=> P; pose E (x : R) := 0 = x \/ P /\ 2 = x.
have HhiE: (hasr (ubr E)) by exists (2 : R); move=> x [<-|[_ <-]] //; apply ltrW.
have HE: has_supr E by split; first by exists (0 : R); left.
case: (supr_total 1 HE) => HE1.
by left; case: HE1 => [x [<-|[HP _]]] // *; case ltr01.
right; move=> HP; case: (ltrSr 1); apply: leqr_trans HE1.
by apply ubr_sup; last by right; split.
Qed.
(* Deciding comparisons. *)
Lemma leqr_eqVlt : forall x1 x2 : R, x1 <= x2 <-> x1 == x2 \/ x1 < x2.
Proof.
move=> x1 x2; rewrite /eqr.
case: (reals_classic (x2 <= x1)) (leqr_total x1 x2); tauto.
Qed.
Lemma ltr_neqAle : forall x1 x2 : R, x1 < x2 <-> x1 != x2 /\ x1 <= x2.
Proof. move=> x1 x2; rewrite (leqr_eqVlt x1 x2) /eqr; tauto. Qed.
(* Deciding definition by cases. *)
Lemma selr_cases : forall P (x1 x2 : R),
pickr_spec P (~ P) x1 x2 (select {x1 if P, else x2}).
Proof. move=> P x1 x2; apply: pickr_cases; try tauto; exact: reals_classic. Qed.
Add Morphism (@selr _ : Prop -> RR -> RR -> RR) : selr_morphism.
Proof.
move=> P Q x1 y1 x2 y2 DP Dx1 Dx2; apply: pickr_morphism; try tauto.
exact: reals_classic.
Qed.
Add Morphism selR : selR_morphism. Proof. unlock selR; exact selr_morphism. Qed.
End RealLemmas.
Implicit Arguments neqr10 [].
Implicit Arguments ltr01 [].
Implicit Arguments ltr02 [].
Implicit Arguments ltrSr [R].
Implicit Arguments ltPrr [R].
Implicit Arguments ltr0Sn [].
Set Strict Implicit.
Unset Implicit Arguments.
|
[STATEMENT]
lemma mkeps_flat:
assumes "nullable r"
shows "flat (mkeps r) = []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. flat (mkeps r) = []
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
nullable r
goal (1 subgoal):
1. flat (mkeps r) = []
[PROOF STEP]
by (induct r) (auto) |
Require Import QArith PArith.
Require Import List.
From Bremen.theories.physics Require Import Frequency.
Import ListNotations.
(* measured in decibel *)
Definition amplitude := Q.
Inductive frequency_amplitude :=
freq_amp : frequency -> amplitude -> frequency_amplitude.
Notation "A 'Hz' B 'dB'" := (freq_amp A B) (at level 85, right associativity).
Definition frequency_sample := list frequency_amplitude.
Example s1 : frequency_sample := [(10.0 Hz 10 dB); (20.0 Hz 9.0 dB); (30.0 Hz 2 dB)].
Definition is_harmonic (a b : frequency_amplitude) : bool :=
match a, b with
| f1 Hz _ dB , f2 Hz _ dB => is_harmonic f1 f2
end.
(* Noise and overlapping harmonics are not considered, but should be. *)
Definition maximum_one_pitch (s : frequency_sample) : bool :=
match s with
| [] => true
| a :: b => forallb (is_harmonic a) b
end
.
Definition lowest_frequency_within (f1 f2 : frequency) (s : frequency_sample) : bool :=
match s with
| [] => true
| (f Hz _ dB) :: _ => andb (Qle_bool f1 f) (Qle_bool f f2)
end.
Fixpoint strength (s : frequency_sample) : Q :=
match s with
| [] => 0.0
| (_ Hz a dB) :: ss => Qplus a (strength ss)
end.
Definition is_musical (s : frequency_sample) : bool :=
true.
Eval compute in lowest_frequency_within 9.0 8.0 s1.
|
-- Copyright 2017, the blau.io contributors
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
||| The original specification can be found at
||| https://infra.spec.whatwg.org/#namespaces
module API.Web.Infra.Namespaces
%access public export
%default total
html : String
html = "http://www.w3.org/1999/xhtml"
mathML : String
mathML = "http://www.w3.org/1998/Math/MathML"
svg : String
svg = "http://www.w3.org/2000/svg"
xLink : String
xLink = "http://www.w3.org/1999/xlink"
xml : String
xml = "http://www.w3.org/XML/1998/namespace"
xmlns : String
xmlns = "http://www.w3.org/2000/xmlns/"
|
import Data.Vect
insert : Ord elem => (x : elem) -> (sorted : Vect k elem) -> Vect (S k) elem
insert x [] = [x]
insert x (y :: xs) = case x < y of
False => y :: insert x xs
True => x :: y :: xs
ins_sort : Ord elem => Vect n elem -> Vect n elem
ins_sort [] = []
ins_sort (x :: xs) = let sorted = ins_sort xs in
insert x sorted
-- *vec_sort> ins_sort ['C', 'A', 'Z']
-- ['A', 'C', 'Z'] : Vect 3 Char
-- *vec_sort> ins_sort [3,2,9,7,6,5,8]
-- [2, 3, 5, 6, 7, 8, 9] : Vect 7 Integer
|
(* Title: CCPO_Topology.thy
Author: Johannes Hölzl, TU Munich
*)
section {* CCPO topologies *}
theory CCPO_Topology
imports
"HOL-Analysis.Extended_Real_Limits"
"../Coinductive_Nat"
begin
lemma dropWhile_append:
"dropWhile P (xs @ ys) = (if \<forall>x\<in>set xs. P x then dropWhile P ys else dropWhile P xs @ ys)"
by auto
lemma dropWhile_False: "(\<And>x. x \<in> set xs \<Longrightarrow> P x) \<Longrightarrow> dropWhile P xs = []"
by simp
abbreviation (in order) "chain \<equiv> Complete_Partial_Order.chain op \<le>"
lemma (in linorder) chain_linorder: "chain C"
by (simp add: chain_def linear)
lemma continuous_add_ereal:
assumes "0 \<le> t"
shows "continuous_on {-\<infinity>::ereal <..} (\<lambda>x. t + x)"
proof (subst continuous_on_open_vimage, (intro open_greaterThan allI impI)+)
fix B :: "ereal set" assume "open B"
show "open ((\<lambda>x. t + x) -` B \<inter> {- \<infinity><..})"
proof (cases t)
case (real t')
then have *: "(\<lambda>x. t + x) -` B \<inter> {- \<infinity><..} = (\<lambda>x. 1 * x + (-t)) ` (B \<inter> {-\<infinity> <..})"
apply (simp add: set_eq_iff image_iff Bex_def)
apply (intro allI iffI)
apply (rule_tac x= "x + ereal t'" in exI)
apply (case_tac x)
apply (auto simp: ac_simps)
done
show ?thesis
unfolding *
apply (rule ereal_open_affinity_pos)
using `open B`
apply (auto simp: real)
done
qed (insert `0 \<le> t`, auto)
qed
lemma tendsto_add_ereal:
"0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> (f \<longlongrightarrow> y) F \<Longrightarrow> ((\<lambda>z. x + f z :: ereal) \<longlongrightarrow> x + y) F"
apply (rule tendsto_compose[where f=f])
using continuous_add_ereal[where t=x]
unfolding continuous_on_def
apply (auto simp add: at_within_open[where S="{- \<infinity> <..}"])
done
lemma tendsto_LimI: "(f \<longlongrightarrow> y) F \<Longrightarrow> (f \<longlongrightarrow> Lim F f) F"
by (metis tendsto_Lim tendsto_bot)
subsection {* The filter @{text at'} *}
abbreviation (in ccpo) "compact_element \<equiv> ccpo.compact Sup op \<le>"
lemma tendsto_unique_eventually:
fixes x x' :: "'a :: t2_space"
shows "F \<noteq> bot \<Longrightarrow> eventually (\<lambda>x. f x = g x) F \<Longrightarrow> (f \<longlongrightarrow> x) F \<Longrightarrow> (g \<longlongrightarrow> x') F \<Longrightarrow> x = x'"
by (metis tendsto_unique filterlim_cong)
lemma (in ccpo) ccpo_Sup_upper2: "chain C \<Longrightarrow> x \<in> C \<Longrightarrow> y \<le> x \<Longrightarrow> y \<le> Sup C"
by (blast intro: ccpo_Sup_upper order_trans)
lemma tendsto_open_vimage: "(\<And>B. open B \<Longrightarrow> open (f -` B)) \<Longrightarrow> f \<midarrow>l\<rightarrow> f l"
using continuous_on_open_vimage[of UNIV f] continuous_on_def[of UNIV f] by simp
lemma open_vimageI: "(\<And>x. f \<midarrow>x\<rightarrow> f x) \<Longrightarrow> open A \<Longrightarrow> open (f -` A)"
using continuous_on_open_vimage[of UNIV f] continuous_on_def[of UNIV f] by simp
lemma principal_bot: "principal x = bot \<longleftrightarrow> x = {}"
by (auto simp: filter_eq_iff eventually_principal)
definition "at' x = (if open {x} then principal {x} else at x)"
lemma at'_bot: "at' x \<noteq> bot"
by (simp add: at'_def at_eq_bot_iff principal_bot)
lemma tendsto_id_at'[simp, intro]: "((\<lambda>x. x) \<longlongrightarrow> x) (at' x)"
by (simp add: at'_def topological_tendstoI eventually_principal tendsto_ident_at)
lemma cont_at': "(f \<longlongrightarrow> f x) (at' x) \<longleftrightarrow> f \<midarrow>x\<rightarrow> f x"
using at_eq_bot_iff[of x] by (auto split: if_split_asm intro!: topological_tendstoI simp: eventually_principal at'_def)
subsection {* The type class @{text ccpo_topology} *}
text {* Temporarily relax type constraints for @{term "open"}. *}
setup {* Sign.add_const_constraint
(@{const_name "open"}, SOME @{typ "'a::open set \<Rightarrow> bool"}) *}
class ccpo_topology = "open" + ccpo +
assumes open_ccpo: "open A \<longleftrightarrow> (\<forall>C. chain C \<longrightarrow> C \<noteq> {} \<longrightarrow> Sup C \<in> A \<longrightarrow> C \<inter> A \<noteq> {})"
begin
lemma open_ccpoD:
assumes "open A" "chain C" "C \<noteq> {}" "Sup C \<in> A"
shows "\<exists>c\<in>C. \<forall>c'\<in>C. c \<le> c' \<longrightarrow> c' \<in> A"
proof (rule ccontr)
assume "\<not> ?thesis"
then have *: "\<And>c. c \<in> C \<Longrightarrow> \<exists>c'\<in>C. c \<le> c' \<and> c' \<notin> A"
by auto
with `chain C` `C \<noteq> {}` have "chain (C - A)" "C - A \<noteq> {}"
by (auto intro: chain_Diff)
moreover have "Sup C = Sup (C - A)"
proof (safe intro!: antisym ccpo_Sup_least `chain C` chain_Diff)
fix c assume "c \<in> C"
with * obtain c' where "c' \<in> C" "c \<le> c'" "c' \<notin> A"
by auto
with `c\<in>C` show "c \<le> \<Squnion>(C - A)"
by (intro ccpo_Sup_upper2 `chain (C - A)`) auto
qed (auto intro: `chain C` ccpo_Sup_upper)
ultimately show False
using `open A` `Sup C \<in> A` by (auto simp: open_ccpo)
qed
lemma open_ccpo_Iic: "open {.. b}"
by (auto simp: open_ccpo) (metis Int_iff atMost_iff ccpo_Sup_upper empty_iff order_trans)
subclass topological_space
proof
show "open (UNIV::'a set)"
unfolding open_ccpo by auto
next
fix S T :: "'a set" assume "open S" "open T"
show "open (S \<inter> T)"
unfolding open_ccpo
proof (intro allI impI)
fix C assume C: "chain C" "C \<noteq> {}" and "\<Squnion>C \<in> S \<inter> T"
with open_ccpoD[OF `open S` C] open_ccpoD[OF `open T` C]
show "C \<inter> (S \<inter> T) \<noteq> {}"
unfolding chain_def by blast
qed
next
fix K :: "'a set set" assume *: "\<forall>D\<in>K. open D"
show "open (\<Union>K)"
unfolding open_ccpo
proof (intro allI impI)
fix C assume "chain C" "C \<noteq> {}" "\<Squnion>C \<in> (\<Union>K)"
with * obtain D where "D \<in> K" "\<Squnion>C \<in> D" "C \<inter> D \<noteq> {}"
by (auto simp: open_ccpo)
then show "C \<inter> (\<Union>K) \<noteq> {}"
by auto
qed
qed
lemma closed_ccpo: "closed A \<longleftrightarrow> (\<forall>C. chain C \<longrightarrow> C \<noteq> {} \<longrightarrow> C \<subseteq> A \<longrightarrow> Sup C \<in> A)"
unfolding closed_def open_ccpo by auto
lemma closed_admissible: "closed {x. P x} \<longleftrightarrow> ccpo.admissible Sup op \<le> P"
unfolding closed_ccpo ccpo.admissible_def by auto
lemma open_singletonI_compact: "compact_element x \<Longrightarrow> open {x}"
using admissible_compact_neq[of Sup "op \<le>" x]
by (simp add: closed_admissible[symmetric] open_closed Collect_neg_eq)
lemma closed_Ici: "closed {.. b}"
by (auto simp: closed_ccpo intro: ccpo_Sup_least)
lemma closed_Iic: "closed {b ..}"
by (auto simp: closed_ccpo intro: ccpo_Sup_upper2)
text {*
@{class ccpo_topology}s are also @{class t2_space}s.
This is necessary to have a unique continuous extension.
*}
subclass t2_space
proof
fix x y :: 'a assume "x \<noteq> y"
show "\<exists>U V. open U \<and> open V \<and> x \<in> U \<and> y \<in> V \<and> U \<inter> V = {}"
proof cases
{ fix x y assume "x \<noteq> y" "x \<le> y"
then have "open {..x} \<and> open (- {..x}) \<and> x \<in> {..x} \<and> y \<in> - {..x} \<and> {..x} \<inter> - {..x} = {}"
by (auto intro: open_ccpo_Iic closed_Ici) }
moreover assume "x \<le> y \<or> y \<le> x"
ultimately show ?thesis
using `x \<noteq> y` by (metis Int_commute)
next
assume "\<not> (x \<le> y \<or> y \<le> x)"
then have "open ({..x} \<inter> - {..y}) \<and> open ({..y} \<inter> - {..x}) \<and>
x \<in> {..x} \<inter> - {..y} \<and> y \<in> {..y} \<inter> - {..x} \<and> ({..x} \<inter> - {..y}) \<inter> ({..y} \<inter> - {..x}) = {}"
by (auto intro: open_ccpo_Iic closed_Ici)
then show ?thesis by auto
qed
qed
end
lemma tendsto_le_ccpo:
fixes f g :: "'a \<Rightarrow> 'b::ccpo_topology"
assumes F: "\<not> trivial_limit F"
assumes x: "(f \<longlongrightarrow> x) F" and y: "(g \<longlongrightarrow> y) F"
assumes ev: "eventually (\<lambda>x. g x \<le> f x) F"
shows "y \<le> x"
proof (rule ccontr)
assume "\<not> y \<le> x"
show False
proof cases
assume "x \<le> y"
with `\<not> y \<le> x`
have "open {..x}" "open (- {..x})" "x \<in> {..x}" "y \<in> - {..x}" "{..x} \<inter> - {..x} = {}"
by (auto intro: open_ccpo_Iic closed_Ici)
with topological_tendstoD[OF x, of "{..x}"] topological_tendstoD[OF y, of "- {..x}"]
have "eventually (\<lambda>z. f z \<le> x) F" "eventually (\<lambda>z. \<not> g z \<le> x) F"
by auto
with ev have "eventually (\<lambda>x. False) F" by eventually_elim (auto intro: order_trans)
with F show False by (auto simp: eventually_False)
next
assume "\<not> x \<le> y"
with `\<not> y \<le> x` have "open ({..x} \<inter> - {..y})" "open ({..y} \<inter> - {..x})"
"x \<in> {..x} \<inter> - {..y}" "y \<in> {..y} \<inter> - {..x}" "({..x} \<inter> - {..y}) \<inter> ({..y} \<inter> - {..x}) = {}"
by (auto intro: open_ccpo_Iic closed_Ici)
with topological_tendstoD[OF x, of "{..x} \<inter> - {..y}"]
topological_tendstoD[OF y, of "{..y} \<inter> - {..x}"]
have "eventually (\<lambda>z. f z \<le> x \<and> \<not> f z \<le> y) F" "eventually (\<lambda>z. g z \<le> y \<and> \<not> g z \<le> x) F"
by auto
with ev have "eventually (\<lambda>x. False) F" by eventually_elim (auto intro: order_trans)
with F show False by (auto simp: eventually_False)
qed
qed
lemma tendsto_ccpoI:
fixes f :: "'a::ccpo_topology \<Rightarrow> 'b::ccpo_topology"
shows "(\<And>C. chain C \<Longrightarrow> C \<noteq> {} \<Longrightarrow> chain (f ` C) \<and> f (Sup C) = Sup (f`C)) \<Longrightarrow> f \<midarrow>x\<rightarrow> f x"
by (intro tendsto_open_vimage) (auto simp: open_ccpo)
lemma tendsto_mcont:
assumes mcont: "mcont Sup op \<le> Sup op \<le> (f :: 'a :: ccpo_topology \<Rightarrow> 'b :: ccpo_topology)"
shows "f \<midarrow>l\<rightarrow> f l"
proof (intro tendsto_ccpoI conjI)
fix C :: "'a set" assume C: "chain C" "C \<noteq> {}"
show "chain (f`C)"
using mcont
by (intro chain_imageI[where le_a="op \<le>"] C) (simp add: mcont_def monotone_def)
show "f (\<Squnion>C) = \<Squnion>(f ` C)"
using mcont C by (simp add: mcont_def cont_def)
qed
subsection {* Instances for @{class ccpo_topology}s and continuity theorems *}
instantiation set :: (type) ccpo_topology
begin
definition open_set :: "'a set set \<Rightarrow> bool" where
"open_set A \<longleftrightarrow> (\<forall>C. chain C \<longrightarrow> C \<noteq> {} \<longrightarrow> Sup C \<in> A \<longrightarrow> C \<inter> A \<noteq> {})"
instance
by intro_classes (simp add: open_set_def)
end
instantiation enat :: ccpo_topology
begin
instance
proof
fix A :: "enat set"
show "open A = (\<forall>C. chain C \<longrightarrow> C \<noteq> {} \<longrightarrow> \<Squnion>C \<in> A \<longrightarrow> C \<inter> A \<noteq> {})"
proof (intro iffI allI impI)
fix C x assume "open A" "chain C" "C \<noteq> {}" "\<Squnion>C \<in> A"
show "C \<inter> A \<noteq> {}"
proof cases
assume "\<Squnion>C = \<infinity>"
with `\<Squnion>C \<in> A` `open A` obtain n where "{enat n <..} \<subseteq> A"
unfolding open_enat_iff by auto
with `\<Squnion>C = \<infinity>` Sup_eq_top_iff[of C] show ?thesis
by (auto simp: top_enat_def)
next
assume "\<Squnion>C \<noteq> \<infinity>"
then obtain n where "C \<subseteq> {.. enat n}"
unfolding Sup_eq_top_iff top_enat_def[symmetric] by (auto simp: not_less top_enat_def)
moreover have "finite {.. enat n}"
by (auto intro: finite_enat_bounded)
ultimately have "finite C"
by (auto intro: finite_subset)
from in_chain_finite[OF `chain C` `finite C` `C \<noteq> {}`] `\<Squnion>C \<in> A` show ?thesis
by auto
qed
next
assume C: "\<forall>C. chain C \<longrightarrow> C \<noteq> {} \<longrightarrow> \<Squnion>C \<in> A \<longrightarrow> C \<inter> A \<noteq> {}"
show "open A"
unfolding open_enat_iff
proof safe
assume "\<infinity> \<in> A"
{ fix C :: "enat set" assume "infinite C"
then have "\<Squnion>C = \<infinity>"
by (auto simp: Sup_enat_def)
with `infinite C` C[THEN spec, of C] `\<infinity> \<in> A` have "C \<inter> A \<noteq> {}"
by auto }
note inf_C = this
show "\<exists>x. {enat x<..} \<subseteq> A"
proof (rule ccontr)
assume "\<not> (\<exists>x. {enat x<..} \<subseteq> A)"
with `\<infinity> \<in> A` have "\<And>x. \<exists>y>x. enat y \<notin> A"
by (simp add: subset_eq Bex_def) (metis enat.exhaust enat_ord_simps(2))
then have "infinite {n. enat n \<notin> A}"
unfolding infinite_nat_iff_unbounded by auto
then have "infinite (enat ` {n. enat n \<notin> A})"
by (auto dest!: finite_imageD)
from inf_C[OF this] show False
by auto
qed
qed
qed
qed
end
lemmas tendsto_inf2[THEN tendsto_compose, tendsto_intros] =
tendsto_mcont[OF mcont_inf2]
lemma isCont_inf2[THEN isCont_o2[rotated]]:
"isCont (\<lambda>x. x \<sqinter> y) (z :: _ :: {ccpo_topology, complete_distrib_lattice})"
by(simp add: isCont_def tendsto_inf2 tendsto_ident_at)
lemmas tendsto_sup1[THEN tendsto_compose, tendsto_intros] =
tendsto_mcont[OF mcont_sup1]
lemma isCont_If: "isCont f x \<Longrightarrow> isCont g x \<Longrightarrow> isCont (\<lambda>x. if Q then f x else g x) x"
by (cases Q) auto
lemma isCont_enat_case: "isCont (f (epred n)) x \<Longrightarrow> isCont g x \<Longrightarrow> isCont (\<lambda>x. co.case_enat (g x) (\<lambda>n. f n x) n) x"
by (cases n rule: enat_coexhaust) auto
end
|
module Main
import Data.String
import Data.Array
main : IO ()
main = do
(cmd::args) <- getArgs
arr <- fromList $ map unpack args
printLn (length arr)
main' arr
where main' : IOArray (List Char) -> IO ()
main' arr = do
putStr "> "
line <- getLine
Just ix <- pure $ parsePositive {a = Int} line | pure ()
True <- pure $ ix < length arr | pure ()
printLn !(index ix arr)
main' arr
|
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.ZCohomology.Groups.Coproduct where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Data.Nat
open import Cubical.Data.Sigma
open import Cubical.Data.Sum as Sum
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.DirProd
open import Cubical.Algebra.Ring
open import Cubical.Algebra.Ring.DirectProd
open import Cubical.HITs.SetTruncation as ST
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.GroupStructure
private variable
ℓ ℓ' : Level
module _
{X : Type ℓ}
{Y : Type ℓ'}
where
open Iso
open IsGroupHom
open GroupStr
Equiv-Coproduct-CoHom : {n : ℕ} → GroupIso (coHomGr n (X ⊎ Y)) (DirProd (coHomGr n X) (coHomGr n Y))
Iso.fun (fst Equiv-Coproduct-CoHom) = ST.rec (isSet× squash₂ squash₂) (λ f → ∣ f ∘ inl ∣₂ , ∣ (f ∘ inr) ∣₂)
Iso.inv (fst Equiv-Coproduct-CoHom) = uncurry
(ST.rec (λ u v p q i j y → squash₂ (u y) (v y) (λ X → p X y) (λ X → q X y) i j)
(λ g → ST.rec squash₂ (λ h → ∣ Sum.rec g h ∣₂)))
Iso.rightInv (fst Equiv-Coproduct-CoHom) = uncurry
(ST.elim (λ x → isProp→isSet λ u v i y → isSet× squash₂ squash₂ _ _ (u y) (v y) i)
(λ g → ST.elim (λ _ → isProp→isSet (isSet× squash₂ squash₂ _ _))
(λ h → refl)))
Iso.leftInv (fst Equiv-Coproduct-CoHom) = ST.elim (λ _ → isProp→isSet (squash₂ _ _))
λ f → cong ∣_∣₂ (funExt (Sum.elim (λ x → refl) (λ x → refl)))
snd Equiv-Coproduct-CoHom = makeIsGroupHom
(ST.elim (λ x → isProp→isSet λ u v i y → isSet× squash₂ squash₂ _ _ (u y) (v y) i)
(λ g → ST.elim (λ _ → isProp→isSet (isSet× squash₂ squash₂ _ _))
λ h → refl))
|
State Before: F : Type ?u.832295
α : Type u_2
β : Type u_1
γ : Type ?u.832304
inst✝² : DecidableEq β
inst✝¹ : Group α
inst✝ : MulAction α β
s t : Finset β
a : α
b : β
⊢ b ∈ a⁻¹ • s ↔ a • b ∈ s State After: no goals Tactic: rw [← smul_mem_smul_finset_iff a, smul_inv_smul] |
/-
Copyright (c) 2018 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import data.multiset.basic
/-!
# Sections of a multiset
-/
namespace multiset
variables {α : Type*}
section sections
/--
The sections of a multiset of multisets `s` consists of all those multisets
which can be put in bijection with `s`, so each element is an member of the corresponding multiset.
-/
def sections (s : multiset (multiset α)) : multiset (multiset α) :=
multiset.rec_on s {0} (λs _ c, s.bind $ λa, c.map (multiset.cons a))
(assume a₀ a₁ s pi, by simp [map_bind, bind_bind a₀ a₁, cons_swap])
@[simp] lemma sections_zero : sections (0 : multiset (multiset α)) = 0 ::ₘ 0 :=
rfl
@[simp] lemma sections_cons (s : multiset (multiset α)) (m : multiset α) :
sections (m ::ₘ s) = m.bind (λa, (sections s).map (multiset.cons a)) :=
rec_on_cons m s
lemma coe_sections : ∀(l : list (list α)),
sections ((l.map (λl:list α, (l : multiset α))) : multiset (multiset α)) =
((l.sections.map (λl:list α, (l : multiset α))) : multiset (multiset α))
| [] := rfl
| (a :: l) :=
begin
simp,
rw [← cons_coe, sections_cons, bind_map_comm, coe_sections l],
simp [list.sections, (∘), list.bind]
end
@[simp] lemma sections_add (s t : multiset (multiset α)) :
sections (s + t) = (sections s).bind (λm, (sections t).map ((+) m)) :=
multiset.induction_on s (by simp)
(assume a s ih, by simp [ih, bind_assoc, map_bind, bind_map, -add_comm])
lemma mem_sections {s : multiset (multiset α)} :
∀{a}, a ∈ sections s ↔ s.rel (λs a, a ∈ s) a :=
multiset.induction_on s (by simp)
(assume a s ih a',
by simp [ih, rel_cons_left, -exists_and_distrib_left, exists_and_distrib_left.symm, eq_comm])
lemma card_sections {s : multiset (multiset α)} : card (sections s) = prod (s.map card) :=
multiset.induction_on s (by simp) (by simp {contextual := tt})
lemma prod_map_sum [comm_semiring α] {s : multiset (multiset α)} :
prod (s.map sum) = sum ((sections s).map prod) :=
multiset.induction_on s (by simp)
(assume a s ih, by simp [ih, map_bind, sum_map_mul_left, sum_map_mul_right])
end sections
end multiset
|
import .basic
universes u v
section circuit
variables {α : Type u} {i j b b' b'' x y c d r s t : α}
[complete_lattice α] [is_atomistic α] [is_coatomistic α] {M : supermatroid α}
namespace supermatroid
/-- A circuit is a minimal dependent element-/
def circuit (M : supermatroid α) : α → Prop := minimals (≤) M.indepᶜ
/-- A cocircuit is a maximally nonspanning element-/
def cocircuit (M : supermatroid α) : α → Prop := maximals (≤) M.spanningᶜ
lemma circuit.not_indep (hc : M.circuit c) : ¬ M.indep c := hc.1
lemma circuit.dep (hc : M.circuit c) : M.dep c := hc.1
lemma circuit.indep_of_lt (hC : M.circuit c) (hiC : i < c) : M.indep i :=
by_contra (λ h, hiC.ne.symm (hC.2 h hiC.le))
def cov_between (x a b : α) : Prop := a ⋖ x ∧ x ⋖ b
lemma foo {a b i i' j : α} (hii' : i ≠ i') (hi_dep : M.dep i) (hi'_dep : M.dep i')
(hi : cov_between i a b) (hi' : cov_between i' a b) (hj : cov_between j a b) : M.dep j :=
begin
intro hj_ind,
have ha := hj_ind.indep_of_le hj.1.le,
end
lemma dep.exists_circuit_le (hx : M.dep x) : ∃ c, M.circuit c ∧ c ≤ x :=
begin
obtain ⟨i,hi⟩ := M.exists_basis_of x,
obtain ⟨z, hzx, hzi, hzx⟩ := exists_atom_of_not_le (λ h, hx (hi.indep_of_le h)),
set ps := {p | is_coatom p ∧ M.dep (p ⊓ (i ⊔ z))} with hps,
refine ⟨Inf ps, ⟨λ hpi, _ ,sorry⟩, le_of_le_forall_coatom (λ q hq hxq, _)⟩,
{ },
convert Inf_le _,
simp only [mem_set_of_eq, hps],
refine ⟨hq, hi.not_indep_of_lt
(lt_of_le_of_ne (le_inf (hi.le.trans hxq) le_sup_left)
(λ h, hzx (by {rw h, simp [hzi.trans hxq]})))
(inf_le_of_right_le (sup_le hi.le hzi))⟩,
--set sc := {x ∈ si | M.indep (Sup ((si.insert z) \ {x}))}.insert z with hsc,
--have hciz : Sup sc ≤ Sup (si.insert z) := Sup_le_Sup (insert_subset_insert (sep_subset _ _)),
-- refine ⟨Sup sc, ⟨λ (hci : M.indep (Sup sc)),_,_⟩,_⟩,
-- { obtain ⟨j,hj,hcj⟩ := hci.le_basis_of hciz, },
end
end supermatroid
end circuit |
Formal statement is: lemma lim_at_infinity_0: fixes l :: "'a::{real_normed_field,field}" shows "(f \<longlongrightarrow> l) at_infinity \<longleftrightarrow> ((f \<circ> inverse) \<longlongrightarrow> l) (at (0::'a))" Informal statement is: If $f$ converges to $l$ at infinity, then $f(1/x)$ converges to $l$ at $0$. |
Formal statement is: lemma isCont_inverse_function: fixes f g :: "real \<Rightarrow> real" assumes d: "0 < d" and inj: "\<And>z. \<bar>z-x\<bar> \<le> d \<Longrightarrow> g (f z) = z" and cont: "\<And>z. \<bar>z-x\<bar> \<le> d \<Longrightarrow> isCont f z" shows "isCont g (f x)" Informal statement is: Suppose $f$ is a function defined on an interval $(x-d, x+d)$ and $g$ is its inverse. If $f$ is continuous at $x$, then $g$ is continuous at $f(x)$. |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Basic types related to coinduction
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Codata.Musical.Notation where
open import Agda.Builtin.Coinduction public
|
= = Habitat , distribution , and ecology = =
|
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data = pd.read_csv("netflix_revenue_2020.csv")
a = data['area']
y = data['years']
r = data['revenue']
#revenue in 2018
i = 0
total_2018 = 0
while i < 16:
total_2018 += r[i]
i += 1
total_2018
#revenue in 2019
i = 16
total_2019 = 0
while i < 32:
total_2019 += r[i]
i += 1
total_2019
#percentage increase 2019
diff_2019 = total_2019 - total_2018
percent_2019 = diff_2019/total_2018
#revenue 2020
i = 32
total_2020 = 0
while i < 40:
total_2020 += r[i]
i += 1
total_2020
#percentage increase 2020
diff_2020 = total_2020 - total_2019
percent_2020 = diff_2020/total_2019
#bar graph
y = np.array([percent_2019, percent_2020])
mylabels = ["2019", "2020"]
plt.bar(mylabels, y)
plt.show()
|
(* Title: HOL/UNITY/UNITY.thy
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
Copyright 1998 University of Cambridge
The basic UNITY theory (revised version, based upon the "co"
operator).
From Misra, "A Logic for Concurrent Programming", 1994.
*)
section \<open>The Basic UNITY Theory\<close>
theory UNITY imports Main begin
definition
"Program =
{(init:: 'a set, acts :: ('a * 'a)set set,
allowed :: ('a * 'a)set set). Id \<in> acts & Id: allowed}"
typedef 'a program = "Program :: ('a set * ('a * 'a) set set * ('a * 'a) set set) set"
morphisms Rep_Program Abs_Program
unfolding Program_def by blast
definition Acts :: "'a program => ('a * 'a)set set" where
"Acts F == (%(init, acts, allowed). acts) (Rep_Program F)"
definition "constrains" :: "['a set, 'a set] => 'a program set" (infixl "co" 60) where
"A co B == {F. \<forall>act \<in> Acts F. act``A \<subseteq> B}"
definition unless :: "['a set, 'a set] => 'a program set" (infixl "unless" 60) where
"A unless B == (A-B) co (A \<union> B)"
definition mk_program :: "('a set * ('a * 'a)set set * ('a * 'a)set set)
=> 'a program" where
"mk_program == %(init, acts, allowed).
Abs_Program (init, insert Id acts, insert Id allowed)"
definition Init :: "'a program => 'a set" where
"Init F == (%(init, acts, allowed). init) (Rep_Program F)"
definition AllowedActs :: "'a program => ('a * 'a)set set" where
"AllowedActs F == (%(init, acts, allowed). allowed) (Rep_Program F)"
definition Allowed :: "'a program => 'a program set" where
"Allowed F == {G. Acts G \<subseteq> AllowedActs F}"
definition stable :: "'a set => 'a program set" where
"stable A == A co A"
definition strongest_rhs :: "['a program, 'a set] => 'a set" where
"strongest_rhs F A == \<Inter>{B. F \<in> A co B}"
definition invariant :: "'a set => 'a program set" where
"invariant A == {F. Init F \<subseteq> A} \<inter> stable A"
definition increasing :: "['a => 'b::{order}] => 'a program set" where
\<comment>\<open>Polymorphic in both states and the meaning of \<open>\<le>\<close>\<close>
"increasing f == \<Inter>z. stable {s. z \<le> f s}"
subsubsection\<open>The abstract type of programs\<close>
lemmas program_typedef =
Rep_Program Rep_Program_inverse Abs_Program_inverse
Program_def Init_def Acts_def AllowedActs_def mk_program_def
lemma Id_in_Acts [iff]: "Id \<in> Acts F"
apply (cut_tac x = F in Rep_Program)
apply (auto simp add: program_typedef)
done
lemma insert_Id_Acts [iff]: "insert Id (Acts F) = Acts F"
by (simp add: insert_absorb)
lemma Acts_nonempty [simp]: "Acts F \<noteq> {}"
by auto
lemma Id_in_AllowedActs [iff]: "Id \<in> AllowedActs F"
apply (cut_tac x = F in Rep_Program)
apply (auto simp add: program_typedef)
done
lemma insert_Id_AllowedActs [iff]: "insert Id (AllowedActs F) = AllowedActs F"
by (simp add: insert_absorb)
subsubsection\<open>Inspectors for type "program"\<close>
lemma Init_eq [simp]: "Init (mk_program (init,acts,allowed)) = init"
by (simp add: program_typedef)
lemma Acts_eq [simp]: "Acts (mk_program (init,acts,allowed)) = insert Id acts"
by (simp add: program_typedef)
lemma AllowedActs_eq [simp]:
"AllowedActs (mk_program (init,acts,allowed)) = insert Id allowed"
by (simp add: program_typedef)
subsubsection\<open>Equality for UNITY programs\<close>
lemma surjective_mk_program [simp]:
"mk_program (Init F, Acts F, AllowedActs F) = F"
apply (cut_tac x = F in Rep_Program)
apply (auto simp add: program_typedef)
apply (drule_tac f = Abs_Program in arg_cong)+
apply (simp add: program_typedef insert_absorb)
done
lemma program_equalityI:
"[| Init F = Init G; Acts F = Acts G; AllowedActs F = AllowedActs G |]
==> F = G"
apply (rule_tac t = F in surjective_mk_program [THEN subst])
apply (rule_tac t = G in surjective_mk_program [THEN subst], simp)
done
lemma program_equalityE:
"[| F = G;
[| Init F = Init G; Acts F = Acts G; AllowedActs F = AllowedActs G |]
==> P |] ==> P"
by simp
lemma program_equality_iff:
"(F=G) =
(Init F = Init G & Acts F = Acts G &AllowedActs F = AllowedActs G)"
by (blast intro: program_equalityI program_equalityE)
subsubsection\<open>co\<close>
lemma constrainsI:
"(!!act s s'. [| act: Acts F; (s,s') \<in> act; s \<in> A |] ==> s': A')
==> F \<in> A co A'"
by (simp add: constrains_def, blast)
lemma constrainsD:
"[| F \<in> A co A'; act: Acts F; (s,s'): act; s \<in> A |] ==> s': A'"
by (unfold constrains_def, blast)
lemma constrains_empty [iff]: "F \<in> {} co B"
by (unfold constrains_def, blast)
lemma constrains_empty2 [iff]: "(F \<in> A co {}) = (A={})"
by (unfold constrains_def, blast)
lemma constrains_UNIV [iff]: "(F \<in> UNIV co B) = (B = UNIV)"
by (unfold constrains_def, blast)
lemma constrains_UNIV2 [iff]: "F \<in> A co UNIV"
by (unfold constrains_def, blast)
text\<open>monotonic in 2nd argument\<close>
lemma constrains_weaken_R:
"[| F \<in> A co A'; A'<=B' |] ==> F \<in> A co B'"
by (unfold constrains_def, blast)
text\<open>anti-monotonic in 1st argument\<close>
lemma constrains_weaken_L:
"[| F \<in> A co A'; B \<subseteq> A |] ==> F \<in> B co A'"
by (unfold constrains_def, blast)
lemma constrains_weaken:
"[| F \<in> A co A'; B \<subseteq> A; A'<=B' |] ==> F \<in> B co B'"
by (unfold constrains_def, blast)
subsubsection\<open>Union\<close>
lemma constrains_Un:
"[| F \<in> A co A'; F \<in> B co B' |] ==> F \<in> (A \<union> B) co (A' \<union> B')"
by (unfold constrains_def, blast)
lemma constrains_UN:
"(!!i. i \<in> I ==> F \<in> (A i) co (A' i))
==> F \<in> (\<Union>i \<in> I. A i) co (\<Union>i \<in> I. A' i)"
by (unfold constrains_def, blast)
lemma constrains_Un_distrib: "(A \<union> B) co C = (A co C) \<inter> (B co C)"
by (unfold constrains_def, blast)
lemma constrains_UN_distrib: "(\<Union>i \<in> I. A i) co B = (\<Inter>i \<in> I. A i co B)"
by (unfold constrains_def, blast)
lemma constrains_Int_distrib: "C co (A \<inter> B) = (C co A) \<inter> (C co B)"
by (unfold constrains_def, blast)
lemma constrains_INT_distrib: "A co (\<Inter>i \<in> I. B i) = (\<Inter>i \<in> I. A co B i)"
by (unfold constrains_def, blast)
subsubsection\<open>Intersection\<close>
lemma constrains_Int:
"[| F \<in> A co A'; F \<in> B co B' |] ==> F \<in> (A \<inter> B) co (A' \<inter> B')"
by (unfold constrains_def, blast)
lemma constrains_INT:
"(!!i. i \<in> I ==> F \<in> (A i) co (A' i))
==> F \<in> (\<Inter>i \<in> I. A i) co (\<Inter>i \<in> I. A' i)"
by (unfold constrains_def, blast)
lemma constrains_imp_subset: "F \<in> A co A' ==> A \<subseteq> A'"
by (unfold constrains_def, auto)
text\<open>The reasoning is by subsets since "co" refers to single actions
only. So this rule isn't that useful.\<close>
lemma constrains_trans:
"[| F \<in> A co B; F \<in> B co C |] ==> F \<in> A co C"
by (unfold constrains_def, blast)
lemma constrains_cancel:
"[| F \<in> A co (A' \<union> B); F \<in> B co B' |] ==> F \<in> A co (A' \<union> B')"
by (unfold constrains_def, clarify, blast)
subsubsection\<open>unless\<close>
lemma unlessI: "F \<in> (A-B) co (A \<union> B) ==> F \<in> A unless B"
by (unfold unless_def, assumption)
lemma unlessD: "F \<in> A unless B ==> F \<in> (A-B) co (A \<union> B)"
by (unfold unless_def, assumption)
subsubsection\<open>stable\<close>
lemma stableI: "F \<in> A co A ==> F \<in> stable A"
by (unfold stable_def, assumption)
lemma stableD: "F \<in> stable A ==> F \<in> A co A"
by (unfold stable_def, assumption)
lemma stable_UNIV [simp]: "stable UNIV = UNIV"
by (unfold stable_def constrains_def, auto)
subsubsection\<open>Union\<close>
lemma stable_Un:
"[| F \<in> stable A; F \<in> stable A' |] ==> F \<in> stable (A \<union> A')"
apply (unfold stable_def)
apply (blast intro: constrains_Un)
done
lemma stable_UN:
"(!!i. i \<in> I ==> F \<in> stable (A i)) ==> F \<in> stable (\<Union>i \<in> I. A i)"
apply (unfold stable_def)
apply (blast intro: constrains_UN)
done
lemma stable_Union:
"(!!A. A \<in> X ==> F \<in> stable A) ==> F \<in> stable (\<Union>X)"
by (unfold stable_def constrains_def, blast)
subsubsection\<open>Intersection\<close>
lemma stable_Int:
"[| F \<in> stable A; F \<in> stable A' |] ==> F \<in> stable (A \<inter> A')"
apply (unfold stable_def)
apply (blast intro: constrains_Int)
done
lemma stable_INT:
"(!!i. i \<in> I ==> F \<in> stable (A i)) ==> F \<in> stable (\<Inter>i \<in> I. A i)"
apply (unfold stable_def)
apply (blast intro: constrains_INT)
done
lemma stable_Inter:
"(!!A. A \<in> X ==> F \<in> stable A) ==> F \<in> stable (\<Inter>X)"
by (unfold stable_def constrains_def, blast)
lemma stable_constrains_Un:
"[| F \<in> stable C; F \<in> A co (C \<union> A') |] ==> F \<in> (C \<union> A) co (C \<union> A')"
by (unfold stable_def constrains_def, blast)
lemma stable_constrains_Int:
"[| F \<in> stable C; F \<in> (C \<inter> A) co A' |] ==> F \<in> (C \<inter> A) co (C \<inter> A')"
by (unfold stable_def constrains_def, blast)
(*[| F \<in> stable C; F \<in> (C \<inter> A) co A |] ==> F \<in> stable (C \<inter> A) *)
lemmas stable_constrains_stable = stable_constrains_Int[THEN stableI]
subsubsection\<open>invariant\<close>
lemma invariantI: "[| Init F \<subseteq> A; F \<in> stable A |] ==> F \<in> invariant A"
by (simp add: invariant_def)
text\<open>Could also say @{term "invariant A \<inter> invariant B \<subseteq> invariant(A \<inter> B)"}\<close>
lemma invariant_Int:
"[| F \<in> invariant A; F \<in> invariant B |] ==> F \<in> invariant (A \<inter> B)"
by (auto simp add: invariant_def stable_Int)
subsubsection\<open>increasing\<close>
lemma increasingD:
"F \<in> increasing f ==> F \<in> stable {s. z \<subseteq> f s}"
by (unfold increasing_def, blast)
lemma increasing_constant [iff]: "F \<in> increasing (%s. c)"
by (unfold increasing_def stable_def, auto)
lemma mono_increasing_o:
"mono g ==> increasing f \<subseteq> increasing (g o f)"
apply (unfold increasing_def stable_def constrains_def, auto)
apply (blast intro: monoD order_trans)
done
(*Holds by the theorem (Suc m \<subseteq> n) = (m < n) *)
lemma strict_increasingD:
"!!z::nat. F \<in> increasing f ==> F \<in> stable {s. z < f s}"
by (simp add: increasing_def Suc_le_eq [symmetric])
(** The Elimination Theorem. The "free" m has become universally quantified!
Should the premise be !!m instead of \<forall>m ? Would make it harder to use
in forward proof. **)
lemma elimination:
"[| \<forall>m \<in> M. F \<in> {s. s x = m} co (B m) |]
==> F \<in> {s. s x \<in> M} co (\<Union>m \<in> M. B m)"
by (unfold constrains_def, blast)
text\<open>As above, but for the trivial case of a one-variable state, in which the
state is identified with its one variable.\<close>
lemma elimination_sing:
"(\<forall>m \<in> M. F \<in> {m} co (B m)) ==> F \<in> M co (\<Union>m \<in> M. B m)"
by (unfold constrains_def, blast)
subsubsection\<open>Theoretical Results from Section 6\<close>
lemma constrains_strongest_rhs:
"F \<in> A co (strongest_rhs F A )"
by (unfold constrains_def strongest_rhs_def, blast)
lemma strongest_rhs_is_strongest:
"F \<in> A co B ==> strongest_rhs F A \<subseteq> B"
by (unfold constrains_def strongest_rhs_def, blast)
subsubsection\<open>Ad-hoc set-theory rules\<close>
lemma Un_Diff_Diff [simp]: "A \<union> B - (A - B) = B"
by blast
lemma Int_Union_Union: "\<Union>B \<inter> A = \<Union>((%C. C \<inter> A)`B)"
by blast
text\<open>Needed for WF reasoning in WFair.thy\<close>
lemma Image_less_than [simp]: "less_than `` {k} = greaterThan k"
by blast
lemma Image_inverse_less_than [simp]: "less_than^-1 `` {k} = lessThan k"
by blast
subsection\<open>Partial versus Total Transitions\<close>
definition totalize_act :: "('a * 'a)set => ('a * 'a)set" where
"totalize_act act == act \<union> Id_on (-(Domain act))"
definition totalize :: "'a program => 'a program" where
"totalize F == mk_program (Init F,
totalize_act ` Acts F,
AllowedActs F)"
definition mk_total_program :: "('a set * ('a * 'a)set set * ('a * 'a)set set)
=> 'a program" where
"mk_total_program args == totalize (mk_program args)"
definition all_total :: "'a program => bool" where
"all_total F == \<forall>act \<in> Acts F. Domain act = UNIV"
lemma insert_Id_image_Acts: "f Id = Id ==> insert Id (f`Acts F) = f ` Acts F"
by (blast intro: sym [THEN image_eqI])
subsubsection\<open>Basic properties\<close>
lemma totalize_act_Id [simp]: "totalize_act Id = Id"
by (simp add: totalize_act_def)
lemma Domain_totalize_act [simp]: "Domain (totalize_act act) = UNIV"
by (auto simp add: totalize_act_def)
lemma Init_totalize [simp]: "Init (totalize F) = Init F"
by (unfold totalize_def, auto)
lemma Acts_totalize [simp]: "Acts (totalize F) = (totalize_act ` Acts F)"
by (simp add: totalize_def insert_Id_image_Acts)
lemma AllowedActs_totalize [simp]: "AllowedActs (totalize F) = AllowedActs F"
by (simp add: totalize_def)
lemma totalize_constrains_iff [simp]: "(totalize F \<in> A co B) = (F \<in> A co B)"
by (simp add: totalize_def totalize_act_def constrains_def, blast)
lemma totalize_stable_iff [simp]: "(totalize F \<in> stable A) = (F \<in> stable A)"
by (simp add: stable_def)
lemma totalize_invariant_iff [simp]:
"(totalize F \<in> invariant A) = (F \<in> invariant A)"
by (simp add: invariant_def)
lemma all_total_totalize: "all_total (totalize F)"
by (simp add: totalize_def all_total_def)
lemma Domain_iff_totalize_act: "(Domain act = UNIV) = (totalize_act act = act)"
by (force simp add: totalize_act_def)
lemma all_total_imp_totalize: "all_total F ==> (totalize F = F)"
apply (simp add: all_total_def totalize_def)
apply (rule program_equalityI)
apply (simp_all add: Domain_iff_totalize_act image_def)
done
lemma all_total_iff_totalize: "all_total F = (totalize F = F)"
apply (rule iffI)
apply (erule all_total_imp_totalize)
apply (erule subst)
apply (rule all_total_totalize)
done
lemma mk_total_program_constrains_iff [simp]:
"(mk_total_program args \<in> A co B) = (mk_program args \<in> A co B)"
by (simp add: mk_total_program_def)
subsection\<open>Rules for Lazy Definition Expansion\<close>
text\<open>They avoid expanding the full program, which is a large expression\<close>
lemma def_prg_Init:
"F = mk_total_program (init,acts,allowed) ==> Init F = init"
by (simp add: mk_total_program_def)
lemma def_prg_Acts:
"F = mk_total_program (init,acts,allowed)
==> Acts F = insert Id (totalize_act ` acts)"
by (simp add: mk_total_program_def)
lemma def_prg_AllowedActs:
"F = mk_total_program (init,acts,allowed)
==> AllowedActs F = insert Id allowed"
by (simp add: mk_total_program_def)
text\<open>An action is expanded if a pair of states is being tested against it\<close>
lemma def_act_simp:
"act = {(s,s'). P s s'} ==> ((s,s') \<in> act) = P s s'"
by (simp add: mk_total_program_def)
text\<open>A set is expanded only if an element is being tested against it\<close>
lemma def_set_simp: "A = B ==> (x \<in> A) = (x \<in> B)"
by (simp add: mk_total_program_def)
subsubsection\<open>Inspectors for type "program"\<close>
lemma Init_total_eq [simp]:
"Init (mk_total_program (init,acts,allowed)) = init"
by (simp add: mk_total_program_def)
lemma Acts_total_eq [simp]:
"Acts(mk_total_program(init,acts,allowed)) = insert Id (totalize_act`acts)"
by (simp add: mk_total_program_def)
lemma AllowedActs_total_eq [simp]:
"AllowedActs (mk_total_program (init,acts,allowed)) = insert Id allowed"
by (auto simp add: mk_total_program_def)
end
|
import geometry.manifold.algebra.smooth_functions
import ring_theory.derivation
import geometry.manifold.temporary_to_be_removed
variables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]
{E : Type*} [normed_group E] [normed_space 𝕜 E]
{H : Type*} [topological_space H] (I : model_with_corners 𝕜 E H)
(M : Type*) [topological_space M] [charted_space H M] [smooth_manifold_with_corners I M]
open_locale manifold
def module_point_derivation (x : M) : module C∞(I, M; 𝕜) 𝕜 :=
{ smul := λ f k, f x * k,
one_smul := λ k, one_mul k,
mul_smul := λ f g k, mul_assoc _ _ _,
smul_add := λ f g k, mul_add _ _ _,
smul_zero := λ f, mul_zero _,
add_smul := λ f g k, add_mul _ _ _,
zero_smul := λ f, zero_mul _ }
def compatible_semimodule_tangent_space (x : M) :
@compatible_semimodule 𝕜 C∞(I, M; 𝕜) _ _ _ 𝕜 _ (module_point_derivation I M x) _ :=
{ compatible_smul := λ h k, rfl, }
@[reducible] def point_derivation (x : M) :=
@derivation 𝕜 C∞(I, M; 𝕜) _ _ _ 𝕜 _ (module_point_derivation I M x) _
(compatible_semimodule_tangent_space I M x)
def tangent_bundle_derivation := Σ x : M, point_derivation I M x
/-instance : has_add (tangent_bundle_derivation I M) :=
{ add := λ v w, sigma.mk v.1 (v.2 + w.2) }-/
variables {I M}
def tangent_space_inclusion {x : M} (v : point_derivation I M x) : tangent_bundle_derivation I M :=
sigma.mk x v
/- Something weird is happening. Does not find the instance of smooth manifolds with corners.
Moreover if I define it as a reducible def .eval does not work... It also takes very long time to
typecheck -/
section
namespace point_derivation
variables {I} {M} {x y : M} {v w : point_derivation I M x} (f g : C∞(I, M; 𝕜)) (r : 𝕜)
lemma coe_injective (h : ⇑v = w) : v = w :=
@derivation.coe_injective 𝕜 _ C∞(I, M; 𝕜) _ _ 𝕜 _ (module_point_derivation I M x) _
(compatible_semimodule_tangent_space I M x) v w h
@[ext] theorem ext (h : ∀ f, v f = w f) : v = w :=
coe_injective $ funext h
variables {u : point_derivation I M y}
theorem hext (h1 : x = y) (h2 : ∀ f, v f = u f) : v == u :=
begin
cases h1,
rw heq_iff_eq at *,
ext,
exact h2 f,
end
end point_derivation
end
section
variables {I} {M} {X Y : vector_field_derivation I M} (f g : C∞(I, M; 𝕜)) (r : 𝕜)
namespace vector_field_derivation
instance : has_coe_to_fun (vector_field_derivation I M) := ⟨_, λ X, X.to_linear_map.to_fun⟩
instance has_coe_to_derivation :
has_coe (vector_field_derivation I M) (derivation 𝕜 C∞(I, M; 𝕜) C∞(I, M; 𝕜)) :=
⟨to_derivation⟩
instance has_coe_to_linear_map :
has_coe (vector_field_derivation I M) (C∞(I, M; 𝕜) →ₗ[𝕜] C∞(I, M; 𝕜)) :=
⟨λ X, X.to_linear_map⟩
@[simp] lemma to_fun_eq_coe : X.to_fun = ⇑X := rfl
@[simp, norm_cast]
lemma coe_linear_map (X : vector_field_derivation I M) :
⇑(X : C∞(I, M; 𝕜) →ₗ[𝕜] C∞(I, M; 𝕜)) = X := rfl
lemma coe_injective (h : ⇑X = Y) : X = Y :=
by { cases X, cases Y, congr', exact derivation.coe_injective h }
@[ext] theorem ext (h : ∀ f, X f = Y f) : X = Y :=
coe_injective $ funext h
variables (X Y)
@[simp] lemma map_add : X (f + g) = X f + X g := derivation.map_add _ _ _
@[simp] lemma map_zero : X 0 = 0 := derivation.map_zero _
@[simp] lemma map_smul : X (r • f) = r • X f := derivation.map_smul _ _ _
@[simp] lemma leibniz : X (f * g) = f • X g + g • X f := derivation.leibniz _ _ _
@[simp] lemma map_one_eq_zero : X 1 = 0 := derivation.map_one_eq_zero _
@[simp] lemma map_neg : X (-f) = -X f := derivation.map_neg _ _
@[simp] lemma map_sub : X (f - g) = X f - X g := derivation.map_sub _ _ _
instance : has_zero (vector_field_derivation I M) := ⟨⟨(0 : derivation 𝕜 C∞(I, M; 𝕜) C∞(I, M; 𝕜))⟩⟩
instance : inhabited (vector_field_derivation I M) := ⟨0⟩
instance : add_comm_group (vector_field_derivation I M) :=
{ add := λ X Y, ⟨X + Y⟩,
add_assoc := λ X Y Z, ext $ λ a, add_assoc _ _ _,
zero_add := λ X, ext $ λ a, zero_add _,
add_zero := λ X, ext $ λ a, add_zero _,
add_comm := λ X Y, ext $ λ a, add_comm _ _,
neg := λ X, ⟨-X⟩,
add_left_neg := λ X, ext $ λ a, add_left_neg _,
..vector_field_derivation.has_zero }
@[simp] lemma add_apply : (X + Y) f = X f + Y f := rfl
@[simp] lemma zero_apply : (0 : vector_field_derivation I M) f = 0 := rfl
instance : has_bracket (vector_field_derivation I M) :=
{ bracket := λ X Y, ⟨⁅X, Y⁆⟩ }
@[simp] lemma commutator_to_derivation_coe : ⁅X, Y⁆.to_derivation = ⁅X, Y⁆ := rfl
@[simp] lemma commutator_coe_derivation :
⇑⁅X, Y⁆ = (⁅X, Y⁆ : derivation 𝕜 C∞(I, M; 𝕜) C∞(I, M; 𝕜)) := rfl
@[simp] lemma commutator_apply : ⁅X, Y⁆ f = X (Y f) - Y (X f) :=
by rw [commutator_coe_derivation, derivation.commutator_apply]; refl
instance : lie_ring (vector_field_derivation I M) :=
{ add_lie := λ X Y Z, by { ext1 f, simp only [commutator_apply, add_apply, map_add], ring, },
lie_add := λ X Y Z, by { ext1 f, simp only [commutator_apply, add_apply, map_add], ring },
lie_self := λ X, by { ext1 f, simp only [commutator_apply, zero_apply, sub_self] },
jacobi := λ X Y Z, by { ext1 f, simp only [commutator_apply, add_apply, map_sub,
zero_apply], ring }, }
instance : has_scalar 𝕜 (vector_field_derivation I M) :=
{ smul := λ k X, ⟨k • X⟩ }
instance kmodule : module 𝕜 (vector_field_derivation I M) :=
semimodule.of_core $
{ mul_smul := λ r s X, ext $ λ b, mul_smul _ _ _,
one_smul := λ X, ext $ λ b, one_smul 𝕜 _,
smul_add := λ r X Y, ext $ λ b, smul_add _ _ _,
add_smul := λ r s X, ext $ λ b, add_smul _ _ _,
..vector_field_derivation.has_scalar }
@[simp] lemma smul_apply : (r • X) f = r • X f := rfl
instance : lie_algebra 𝕜 (vector_field_derivation I M) :=
{ lie_smul := λ X Y Z, by { ext1 f, simp only [commutator_apply, smul_apply, map_smul, smul_sub] },
..vector_field_derivation.kmodule, }
def eval (X : vector_field_derivation I M) (x : M) : point_derivation I M x :=
{ to_fun := λ f, (X f) x,
map_add' := λ f g, by { rw map_add, refl },
map_smul' := λ f g, by { rw [map_smul, algebra.id.smul_eq_mul], refl },
leibniz' := λ h k, by { dsimp only [], rw [leibniz, algebra.id.smul_eq_mul], refl } }
@[simp] lemma eval_apply (x : M) : X.eval x f = (X f) x := rfl
@[simp] lemma eval_add (x : M) :
(X + Y).eval x = X.eval x + Y.eval x :=
by ext f; simp only [derivation.add_apply, add_apply, eval_apply, smooth_map.add_apply]
/- to be moved -/
@[simp] lemma ring_commutator.apply {α : Type*} {R : Type*} [ring R] (f g : α → R) (a : α) :
⁅f, g⁆ a = ⁅f a, g a⁆ :=
by simp only [ring_commutator.commutator, pi.mul_apply, pi.sub_apply]
/- instance : has_coe_to_fun (vector_field_derivation I M) := ⟨_, λ X, eval X⟩ polymorphysm of coercions to functions is not possible? -/
end vector_field_derivation
variables {E' : Type*} [normed_group E'] [normed_space 𝕜 E']
{H' : Type*} [topological_space H'] {I' : model_with_corners 𝕜 E' H'}
{M' : Type*} [topological_space M'] [charted_space H' M'] [smooth_manifold_with_corners I' M']
def fdifferential (f : C∞(I, M; I', M')) (x : M) (v : point_derivation I M x) : (point_derivation I' M' (f x)) :=
{ to_fun := λ g, v (g.comp f),
map_add' := λ g h, by { rw smooth_map.add_comp, },
map_smul' := λ k g, by { rw smooth_map.smul_comp, },
leibniz' := λ f g, by {dsimp only [], sorry}, } /-TODO: change it so that it is a linear map -/
localized "notation `fd` := fdifferential" in manifold
lemma apply_fdifferential (f : C∞(I, M; I', M')) (x : M) (v : point_derivation I M x) (g : C∞(I', M'; 𝕜)) :
fd f x v g = v (g.comp f) := rfl
variables {E'' : Type*} [normed_group E''] [normed_space 𝕜 E'']
{H'' : Type*} [topological_space H''] {I'' : model_with_corners 𝕜 E'' H''}
{M'' : Type*} [topological_space M''] [charted_space H'' M''] [smooth_manifold_with_corners I'' M'']
@[simp] lemma fdifferential_comp (g : C∞(I', M'; I'', M'')) (f : C∞(I, M; I', M')) (x : M) :
(fd g (f x)) ∘ (fd f x) = fd (g.comp f) x :=
by { ext, simp only [apply_fdifferential], refl }
end
|
{-# OPTIONS --safe #-}
module Cubical.Functions.Surjection where
open import Cubical.Core.Everything
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Functions.Embedding
open import Cubical.HITs.PropositionalTruncation as PropTrunc
private
variable
ℓ ℓ' : Level
A : Type ℓ
B : Type ℓ'
f : A → B
isSurjection : (A → B) → Type _
isSurjection f = ∀ b → ∥ fiber f b ∥
_↠_ : Type ℓ → Type ℓ' → Type (ℓ-max ℓ ℓ')
A ↠ B = Σ[ f ∈ (A → B) ] isSurjection f
section→isSurjection : {g : B → A} → section f g → isSurjection f
section→isSurjection {g = g} s b = ∣ g b , s b ∣
isPropIsSurjection : isProp (isSurjection f)
isPropIsSurjection = isPropΠ λ _ → squash
isEquiv→isSurjection : isEquiv f → isSurjection f
isEquiv→isSurjection e b = ∣ fst (equiv-proof e b) ∣
isEquiv→isEmbedding×isSurjection : isEquiv f → isEmbedding f × isSurjection f
isEquiv→isEmbedding×isSurjection e = isEquiv→isEmbedding e , isEquiv→isSurjection e
isEmbedding×isSurjection→isEquiv : isEmbedding f × isSurjection f → isEquiv f
equiv-proof (isEmbedding×isSurjection→isEquiv {f = f} (emb , sur)) b =
inhProp→isContr (PropTrunc.rec fib' (λ x → x) fib) fib'
where
hpf : hasPropFibers f
hpf = isEmbedding→hasPropFibers emb
fib : ∥ fiber f b ∥
fib = sur b
fib' : isProp (fiber f b)
fib' = hpf b
isEquiv≃isEmbedding×isSurjection : isEquiv f ≃ isEmbedding f × isSurjection f
isEquiv≃isEmbedding×isSurjection = isoToEquiv (iso
isEquiv→isEmbedding×isSurjection
isEmbedding×isSurjection→isEquiv
(λ _ → isOfHLevelΣ 1 isPropIsEmbedding (\ _ → isPropIsSurjection) _ _)
(λ _ → isPropIsEquiv _ _ _))
-- obs: for epi⇒surjective to go through we require a stronger
-- hypothesis that one would expect:
-- f must cancel functions from a higher universe.
rightCancellable : (f : A → B) → Type _
rightCancellable {ℓ} {A} {ℓ'} {B} f = ∀ {C : Type (ℓ-suc (ℓ-max ℓ ℓ'))}
→ ∀ (g g' : B → C) → (∀ x → g (f x) ≡ g' (f x)) → ∀ y → g y ≡ g' y
-- This statement is in Mac Lane & Moerdijk (page 143, corollary 5).
epi⇒surjective : (f : A → B) → rightCancellable f → isSurjection f
epi⇒surjective f rc y = transport (fact₂ y) tt*
where hasPreimage : (A → B) → B → _
hasPreimage f y = ∥ fiber f y ∥
fact₁ : ∀ x → Unit* ≡ hasPreimage f (f x)
fact₁ x = hPropExt isPropUnit*
propTruncIsProp
(λ _ → ∣ (x , refl) ∣)
(λ _ → tt*)
fact₂ : ∀ y → Unit* ≡ hasPreimage f y
fact₂ = rc _ _ fact₁
|
Kmm Cab Co Davis Taxi Service is a Sacramentobased cab service that does rides between Davis and Sacramento, the regional airports, etc. They do not do intraDavis rides. You need to make reservations in advance; you can make them via their website.
Need a ride? Check out the Taxi Services page.
|
Formal statement is: lemma poly_const_conv: fixes x :: "'a::comm_ring_1" shows "poly [:c:] x = y \<longleftrightarrow> c = y" Informal statement is: For any commutative ring $R$ and any $x \in R$, the polynomial $p(x) = c$ is equal to $y$ if and only if $c = y$. |
#' woo.
#'
#' @name woo
#' @docType package
NULL
|
State Before: k : Type u_1
M : Type u_2
N : Type ?u.89573
inst✝³ : LinearOrderedField k
inst✝² : OrderedAddCommGroup M
inst✝¹ : Module k M
inst✝ : OrderedSMul k M
a b : M
c : k
hc : c < 0
⊢ c • a ≤ c • b ↔ b ≤ a State After: k : Type u_1
M : Type u_2
N : Type ?u.89573
inst✝³ : LinearOrderedField k
inst✝² : OrderedAddCommGroup M
inst✝¹ : Module k M
inst✝ : OrderedSMul k M
a b : M
c : k
hc : c < 0
⊢ -c • b ≤ -c • a ↔ b ≤ a Tactic: rw [← neg_neg c, neg_smul, neg_smul (-c), neg_le_neg_iff] State Before: k : Type u_1
M : Type u_2
N : Type ?u.89573
inst✝³ : LinearOrderedField k
inst✝² : OrderedAddCommGroup M
inst✝¹ : Module k M
inst✝ : OrderedSMul k M
a b : M
c : k
hc : c < 0
⊢ -c • b ≤ -c • a ↔ b ≤ a State After: no goals Tactic: exact smul_le_smul_iff_of_pos (neg_pos_of_neg hc) |
REBOL [
Title: "Read-deep"
Rights: {
Copyright 2018 Brett Handley
}
License: {
Licensed under the Apache License, Version 2.0
See: http://www.apache.org/licenses/LICENSE-2.0
}
Author: "Brett Handley"
Purpose: "Recursive READ strategies."
]
;; read-deep-seq aims to be as simple as possible. I.e. relative paths
;; can be derived after the fact. It uses a state to next state approach
;; which means client code can use it iteratively which is useful to avoid
;; reading the full tree up front, or for sort/merge type routines.
;; The root (seed) path is included as the first result.
;; Output can be made relative by stripping the root (seed) path from
;; each returned file.
;;
read-deep-seq: funct [
{Process next file in queue, adding next steps to queue.}
queue [block!]
][
item: take queue
if equal? #"/" last item [
insert queue map-each x read item [join item x]
]
item
]
;; read-deep provides convenience over read-deep-seq.
;;
read-deep: funct [
{Read file or url including subfolders.}
root [file! url! block!]
/full {Includes root path and retains full paths instead returning relative paths.}
/strategy {Allows Queue building to be overridden.}
take [function!] {TAKE next item from queue, building the queue as necessary.}
][
unless strategy [take: :read-deep-seq]
result: make block! []
queue: compose [(root)]
while [not tail? queue][
path: take queue
append result :path ; Voids filtered out.
]
unless full [
remove result ; No need for root in result.
len: length? root
for i 1 length? result 1 [
; Strip off root path from locked paths.
poke result i copy skip result/:i len
]
]
result
]
;; Builds a tree suitable for storing attributes.
;; - One can compose/deep this tree to yield a concise file tree.
;; It is not clear that this sequence idea composes convienently.
;; E.g. Should void DATA or SOURCE be a filter for nodes - may want to exclude some results.
;; Should void CHILD be a filter - need to avoid reads on some folders.
;; - and of course every child is a node
;; It's possible to not take the first item from the queue and just rewrite it
;; allowing a following sequence function to take it. One could chain these, but
;; then there will be two different type of queue processing functions, ones that perform a
;; take and those that just poke the first item.
;; And Should read by wrapped by attempt for specific situations?
grow-read-tree: funct [
{Grow next tree node in queue, where each node represents a file or folder.}
queue [block!]
] [
node: take queue
; Take node as input.
data: node/1
if not equal? #"/" last data/2 [
do make error! rejoin ["Expected queue of folders got:" mold data/2]
]
source: either %./ = data/1 [data/2][join data/1 data/2]
; Finalise folder data.
; ...
; Add node children.
child-nodes: map-each x read source [
data: reduce [source x]
either equal? #"/" last x [
child: reduce [to paren! data]
insert/only queue child ; Only folder nodes are queued.
][
child: to paren! data
]
child
]
append node child-nodes
new-line/all next node true
node ; return current work item.
]
read-tree: funct [
{Return a concise tree from a deep read.}
root [file! url!] "Seed path."
][
tree: reduce [
to paren! reduce [%"" root]
]
take: :grow-read-tree
queue: reduce [tree]
while [not tail? queue][
take queue
]
tree
]
;; Builds a concise tree suitable for displaying folder structure.
;; - This can also be obtained by using compose/deep on read-tree,
;; but this version does less work.
;;
grow-file-tree: funct [
{Grow next tree node in queue, where each node represents a file or folder.}
queue [block!]
] [
node: take queue
; Take node as input.
data: node/1
if not equal? #"/" last data/2 [
fail ["Expected queue of folders got:" mold data/2]
]
source: either %./ = data/1 [data/2][join data/1 data/2]
; Finalise folder data.
poke node 1 data/2
; Add node children.
child-nodes: map-each x read source [
either equal? #"/" last x [
data: reduce [source x]
child: reduce [to paren! data]
insert/only queue child ; Only folder nodes are queued.
][
child: x
]
child
]
append node child-nodes
new-line/all next node true
node ; return current work item.
]
file-tree: funct [
{Return a concise tree from a deep read.}
root [file! url!] "Seed path."
][
tree: reduce [
reduce [%"" root]
]
take: :grow-file-tree
queue: reduce [tree]
while [not tail? queue][
take queue
]
tree
]
|
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(ggplot2))
# Load helper functions
source(file.path("scripts", "util.R"))
# Create theme
correlation_theme <- theme(axis.text.x = element_text(angle = 90,
size = 5),
plot.title = element_text(hjust = 0.5),
strip.background = element_rect(colour = "black",
fill = "#fdfff4"),
legend.text = element_text(size = 8),
legend.key.size = unit(0.7, 'lines'))
# Create list for data storage
sample_correlation_list <- list()
dataset_name <- "TARGET"
# 1) Load phenotype data
target_file <- file.path("..", "0.expression-download", "download", "TARGET_phenotype.gz")
target_pheno_df <- readr::read_tsv(target_file,
col_types = readr::cols(
.default = readr::col_character()))
colnames(target_pheno_df)[2] <- 'sample_type'
# 2) Load sample correlation data
sample_correlation_list[[dataset_name]] <- compile_sample_correlation(dataset_name = dataset_name)
# 3) Merge phenotype and sample correlation results
sample_correlation_list[[dataset_name]] <-
sample_correlation_list[[dataset_name]] %>%
dplyr::full_join(target_pheno_df, by = c("id" = "sample_id")) %>%
na.omit
out_file <- file.path("results", "TARGET_sample_correlation_phenotype.tsv.gz")
readr::write_tsv(sample_correlation_list[[dataset_name]], out_file)
head(sample_correlation_list[[dataset_name]], 2)
# 4) Summarize correlations per sample-type and write to file
disease_summary_df <- sample_correlation_list[[dataset_name]] %>%
dplyr::group_by(algorithm, sample_type, num_comp, cor_type, shuffled, data) %>%
dplyr::summarize(mean_cor = mean(correlation),
var_cor = var(correlation))
out_file <- file.path("results", paste0(dataset_name, "_sample_correlation_phenotype_summary.tsv.gz"))
readr::write_tsv(disease_summary_df, out_file)
head(disease_summary_df)
dataset_name <- "TCGA"
# 1) Load phenotype data
tcga_file <- file.path("..", "0.expression-download", "data", "tcga_sample_identifiers.tsv")
tcga_pheno_df <- readr::read_tsv(tcga_file,
col_types = readr::cols(
.default = readr::col_character()))
colnames(tcga_pheno_df)[2] <- 'sample_class'
colnames(tcga_pheno_df)[3] <- 'sample_type'
# 2) Load sample correlation data
sample_correlation_list[[dataset_name]] <- compile_sample_correlation(dataset_name = dataset_name)
# 3) Merge phenotype and sample correlation results
sample_correlation_list[[dataset_name]] <-
sample_correlation_list[[dataset_name]] %>%
dplyr::full_join(tcga_pheno_df, by = c("id" = "sample_id")) %>%
na.omit
out_file <- file.path("results", "TCGA_sample_correlation_phenotype.tsv.gz")
readr::write_tsv(sample_correlation_list[[dataset_name]], out_file)
head(sample_correlation_list[[dataset_name]], 2)
# 4) Summarize correlations per sample-type and write to file
disease_summary_df <- sample_correlation_list[[dataset_name]] %>%
dplyr::group_by(algorithm, sample_type, num_comp, cor_type, shuffled, data) %>%
dplyr::summarize(mean_cor = mean(correlation),
var_cor = var(correlation))
out_file <- file.path("results", paste0(dataset_name, "_sample_correlation_phenotype_summary.tsv.gz"))
readr::write_tsv(disease_summary_df, out_file)
head(disease_summary_df)
dataset_name <- "GTEX"
# 1) Load phenotype data
gtex_file <- file.path("..", "0.expression-download", "download",
"GTEx_v7_Annotations_SampleAttributesDS.txt")
gtex_pheno_df <- readr::read_tsv(gtex_file,
col_types = readr::cols(
.default = readr::col_character()))
colnames(gtex_pheno_df)[1] <- 'sample_id'
colnames(gtex_pheno_df)[6] <- 'sample_type'
# Subset gtex phenotype file for plotting
gtex_pheno_df <- gtex_pheno_df[, c('sample_id', 'sample_type')]
head(gtex_pheno_df, 2)
# 2) Load sample correlation data
sample_correlation_list[[dataset_name]] <- compile_sample_correlation(dataset_name = dataset_name)
# 3) Merge phenotype and sample correlation results
sample_correlation_list[[dataset_name]] <-
sample_correlation_list[[dataset_name]] %>%
dplyr::full_join(gtex_pheno_df, by = c("id" = "sample_id")) %>%
na.omit
out_file <- file.path("results", "GTEX_sample_correlation_phenotype.tsv.gz")
readr::write_tsv(sample_correlation_list[[dataset_name]], out_file)
head(sample_correlation_list[[dataset_name]], 2)
# 4) Summarize correlations per sample-type and write to file
disease_summary_df <- sample_correlation_list[[dataset_name]] %>%
dplyr::group_by(algorithm,
sample_type,
num_comp,
cor_type,
shuffled,
data) %>%
dplyr::summarize(mean_cor = mean(correlation),
var_cor = var(correlation))
out_file <- file.path("results",
paste0(dataset_name, "_sample_correlation_phenotype_summary.tsv.gz"))
readr::write_tsv(disease_summary_df, out_file)
head(disease_summary_df)
for (dataset_name in names(sample_correlation_list)) {
# Extract out the specific dataset correlation data
sample_corr_df <- sample_correlation_list[[dataset_name]]
# Loop through the datatype
for (data_type in c("signal", "shuffled")) {
# Loop over the correlation type
for (correlation_type in c("pearson", "spearman")) {
print(paste("Processing... ",
dataset_name, data_type, correlation_type))
# Execute the plotting logic
plot_sample_correlation(dataset_name = dataset_name,
data_df = sample_corr_df,
data_type = data_type,
correlation_type = correlation_type,
use_theme = correlation_theme,
return_figures = FALSE)
}
}
}
|
/-
Copyright (c) 2022 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang
-/
import algebra.category.Group.equivalence_Group_AddGroup
import group_theory.quotient_group
/-!
# Monomorphisms and epimorphisms in `Group`
In this file, we prove monomorphisms in category of group are injective homomorphisms and
epimorphisms are surjective homomorphisms.
-/
noncomputable theory
universes u v
namespace monoid_hom
open quotient_group
variables {A : Type u} {B : Type v}
section
variables [group A] [group B]
@[to_additive add_monoid_hom.ker_eq_bot_of_cancel]
lemma ker_eq_bot_of_cancel {f : A →* B} (h : ∀ (u v : f.ker →* A), f.comp u = f.comp v → u = v) :
f.ker = ⊥ :=
by simpa using _root_.congr_arg range (h f.ker.subtype 1 (by tidy))
end
section
variables [comm_group A] [comm_group B]
@[to_additive add_monoid_hom.range_eq_top_of_cancel]
lemma range_eq_top_of_cancel {f : A →* B}
(h : ∀ (u v : B →* B ⧸ f.range), u.comp f = v.comp f → u = v) :
f.range = ⊤ :=
begin
specialize h 1 (quotient_group.mk' _) _,
{ ext1,
simp only [one_apply, coe_comp, coe_mk', function.comp_app],
rw [show (1 : B ⧸ f.range) = (1 : B), from quotient_group.coe_one _, quotient_group.eq,
inv_one, one_mul],
exact ⟨x, rfl⟩, },
replace h : (quotient_group.mk' _).ker = (1 : B →* B ⧸ f.range).ker := by rw h,
rwa [ker_one, quotient_group.ker_mk] at h,
end
end
end monoid_hom
section
open category_theory
namespace Group
variables {A B : Group.{u}} (f : A ⟶ B)
@[to_additive AddGroup.ker_eq_bot_of_mono]
lemma ker_eq_bot_of_mono [mono f] : f.ker = ⊥ :=
monoid_hom.ker_eq_bot_of_cancel $ λ u v,
(@cancel_mono _ _ _ _ _ f _ (show Group.of f.ker ⟶ A, from u) _).1
@[to_additive AddGroup.mono_iff_ker_eq_bot]
lemma mono_iff_ker_eq_bot : mono f ↔ f.ker = ⊥ :=
⟨λ h, @@ker_eq_bot_of_mono f h,
λ h, concrete_category.mono_of_injective _ $ (monoid_hom.ker_eq_bot_iff f).1 h⟩
@[to_additive AddGroup.mono_iff_injective]
lemma mono_iff_injective : mono f ↔ function.injective f :=
iff.trans (mono_iff_ker_eq_bot f) $ monoid_hom.ker_eq_bot_iff f
namespace surjective_of_epi_auxs
local notation `X` := set.range (function.swap left_coset f.range.carrier)
/--
Define `X'` to be the set of all left cosets with an extra point at "infinity".
-/
@[nolint has_nonempty_instance]
inductive X_with_infinity
| from_coset : set.range (function.swap left_coset f.range.carrier) → X_with_infinity
| infinity : X_with_infinity
open X_with_infinity equiv.perm
open_locale coset
local notation `X'` := X_with_infinity f
local notation `∞` := X_with_infinity.infinity
local notation `SX'` := equiv.perm X'
instance : has_smul B X' :=
{ smul := λ b x, match x with
| from_coset y := from_coset ⟨b *l y,
begin
rw [←subtype.val_eq_coe, ←y.2.some_spec, left_coset_assoc],
use b * y.2.some,
end⟩
| ∞ := ∞
end }
lemma mul_smul (b b' : B) (x : X') : (b * b') • x = b • b' • x :=
match x with
| from_coset y :=
begin
change from_coset _ = from_coset _,
simp only [←subtype.val_eq_coe, left_coset_assoc],
end
| ∞ := rfl
end
lemma one_smul (x : X') : (1 : B) • x = x :=
match x with
| from_coset y :=
begin
change from_coset _ = from_coset _,
simp only [←subtype.val_eq_coe, one_left_coset, subtype.ext_iff_val],
end
| ∞ := rfl
end
lemma from_coset_eq_of_mem_range {b : B} (hb : b ∈ f.range) :
from_coset ⟨b *l f.range.carrier, ⟨b, rfl⟩⟩ =
from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩ :=
begin
congr,
change b *l f.range = f.range,
nth_rewrite 1 [show (f.range : set B) = 1 *l f.range, from (one_left_coset _).symm],
rw [left_coset_eq_iff, mul_one],
exact subgroup.inv_mem _ hb,
end
lemma from_coset_ne_of_nin_range {b : B} (hb : b ∉ f.range) :
from_coset ⟨b *l f.range.carrier, ⟨b, rfl⟩⟩ ≠
from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩ :=
begin
intros r,
simp only [subtype.mk_eq_mk] at r,
change b *l f.range = f.range at r,
nth_rewrite 1 [show (f.range : set B) = 1 *l f.range, from (one_left_coset _).symm] at r,
rw [left_coset_eq_iff, mul_one] at r,
exact hb (inv_inv b ▸ (subgroup.inv_mem _ r)),
end
instance : decidable_eq X' := classical.dec_eq _
/--
Let `τ` be the permutation on `X'` exchanging `f.range` and the point at infinity.
-/
noncomputable def tau : SX' :=
equiv.swap (from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩) ∞
local notation `τ` := tau f
lemma τ_apply_infinity :
τ ∞ = from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩ :=
equiv.swap_apply_right _ _
lemma τ_apply_from_coset :
τ (from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩) = ∞ :=
equiv.swap_apply_left _ _
lemma τ_apply_from_coset' (x : B) (hx : x ∈ f.range) :
τ (from_coset ⟨x *l f.range.carrier, ⟨x, rfl⟩⟩) = ∞ :=
(from_coset_eq_of_mem_range _ hx).symm ▸ τ_apply_from_coset _
lemma τ_symm_apply_from_coset :
(equiv.symm τ) (from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩) = ∞ :=
by rw [tau, equiv.symm_swap, equiv.swap_apply_left]
lemma τ_symm_apply_infinity :
(equiv.symm τ) ∞ = from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩ :=
by rw [tau, equiv.symm_swap, equiv.swap_apply_right]
/--
Let `g : B ⟶ S(X')` be defined as such that, for any `β : B`, `g(β)` is the function sending
point at infinity to point at infinity and sending coset `y` to `β *l y`.
-/
def G : B →* SX' :=
{ to_fun := λ β,
{ to_fun := λ x, β • x,
inv_fun := λ x, β⁻¹ • x,
left_inv := λ x, by { dsimp only, rw [←mul_smul, mul_left_inv, one_smul] },
right_inv := λ x, by { dsimp only, rw [←mul_smul, mul_right_inv, one_smul] } },
map_one' := by { ext, simp [one_smul] },
map_mul' := λ b1 b2, by { ext, simp [mul_smul] } }
local notation `g` := G f
/--
Define `h : B ⟶ S(X')` to be `τ g τ⁻¹`
-/
def H : B →* SX':=
{ to_fun := λ β, ((τ).symm.trans (g β)).trans τ,
map_one' := by { ext, simp },
map_mul' := λ b1 b2, by { ext, simp } }
local notation `h` := H f
/-!
The strategy is the following: assuming `epi f`
* prove that `f.range = {x | h x = g x}`;
* thus `f ≫ h = f ≫ g` so that `h = g`;
* but if `f` is not surjective, then some `x ∉ f.range`, then `h x ≠ g x` at the coset `f.range`.
-/
lemma g_apply_infinity (x : B) : (g x) ∞ = ∞ := rfl
lemma h_apply_infinity (x : B) (hx : x ∈ f.range) : (h x) ∞ = ∞ :=
begin
simp only [H, monoid_hom.coe_mk, equiv.to_fun_as_coe, equiv.coe_trans, function.comp_app],
rw [τ_symm_apply_infinity, g_apply_from_coset],
simpa only [←subtype.val_eq_coe] using τ_apply_from_coset' f x hx,
end
lemma h_apply_from_coset (x : B) :
(h x) (from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩) =
from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩ :=
by simp [H, τ_symm_apply_from_coset, g_apply_infinity, τ_apply_infinity]
lemma h_apply_from_coset' (x : B) (b : B) (hb : b ∈ f.range):
(h x) (from_coset ⟨b *l f.range.carrier, ⟨b, rfl⟩⟩) =
from_coset ⟨b *l f.range.carrier, ⟨b, rfl⟩⟩ :=
(from_coset_eq_of_mem_range _ hb).symm ▸ h_apply_from_coset f x
lemma h_apply_from_coset_nin_range (x : B) (hx : x ∈ f.range) (b : B) (hb : b ∉ f.range) :
(h x) (from_coset ⟨b *l f.range.carrier, ⟨b, rfl⟩⟩) =
from_coset ⟨(x * b) *l f.range.carrier, ⟨x * b, rfl⟩⟩ :=
begin
simp only [H, tau, monoid_hom.coe_mk, equiv.to_fun_as_coe, equiv.coe_trans, function.comp_app],
rw [equiv.symm_swap, @equiv.swap_apply_of_ne_of_ne X' _
(from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩) ∞
(from_coset ⟨b *l f.range.carrier, ⟨b, rfl⟩⟩) (from_coset_ne_of_nin_range _ hb) (by simp)],
simp only [g_apply_from_coset, ←subtype.val_eq_coe, left_coset_assoc],
refine equiv.swap_apply_of_ne_of_ne (from_coset_ne_of_nin_range _ (λ r, hb _)) (by simp),
convert subgroup.mul_mem _ (subgroup.inv_mem _ hx) r,
rw [←mul_assoc, mul_left_inv, one_mul],
end
lemma agree : f.range.carrier = {x | h x = g x} :=
begin
refine set.ext (λ b, ⟨_, λ (hb : h b = g b), classical.by_contradiction (λ r, _)⟩),
{ rintros ⟨a, rfl⟩,
change h (f a) = g (f a),
ext ⟨⟨_, ⟨y, rfl⟩⟩⟩,
{ rw [g_apply_from_coset],
by_cases m : y ∈ f.range,
{ rw [h_apply_from_coset' _ _ _ m, from_coset_eq_of_mem_range _ m],
change from_coset _ = from_coset ⟨f a *l (y *l _), _⟩,
simpa only [←from_coset_eq_of_mem_range _ (subgroup.mul_mem _ ⟨a, rfl⟩ m),
left_coset_assoc] },
{ rw [h_apply_from_coset_nin_range _ _ ⟨_, rfl⟩ _ m],
simpa only [←subtype.val_eq_coe, left_coset_assoc], }, },
{ rw [g_apply_infinity, h_apply_infinity _ _ ⟨_, rfl⟩], } },
{ have eq1 : (h b) (from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩) =
(from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩) := by simp [H, tau, g_apply_infinity],
have eq2 : (g b) (from_coset ⟨f.range.carrier, ⟨1, one_left_coset _⟩⟩) =
(from_coset ⟨b *l f.range.carrier, ⟨b, rfl⟩⟩) := rfl,
exact (from_coset_ne_of_nin_range _ r).symm (by rw [←eq1, ←eq2, fun_like.congr_fun hb]) }
end
lemma comp_eq : f ≫ (show B ⟶ Group.of SX', from g) = f ≫ h :=
fun_like.ext _ _ $ λ a,
by simp only [comp_apply, show h (f a) = _, from (by simp [←agree] : f a ∈ {b | h b = g b})]
lemma g_ne_h (x : B) (hx : x ∉ f.range) : g ≠ h :=
begin
intros r,
replace r := fun_like.congr_fun (fun_like.congr_fun r x)
((from_coset ⟨f.range, ⟨1, one_left_coset _⟩⟩)),
rw [H, g_apply_from_coset, monoid_hom.coe_mk, tau] at r,
simp only [monoid_hom.coe_range, subtype.coe_mk, equiv.symm_swap,
equiv.to_fun_as_coe, equiv.coe_trans, function.comp_app] at r,
erw [equiv.swap_apply_left, g_apply_infinity, equiv.swap_apply_right] at r,
exact from_coset_ne_of_nin_range _ hx r,
end
end surjective_of_epi_auxs
lemma surjective_of_epi [epi f] : function.surjective f :=
begin
by_contra r,
push_neg at r,
rcases r with ⟨b, hb⟩,
exact surjective_of_epi_auxs.g_ne_h f b (λ ⟨c, hc⟩, hb _ hc)
((cancel_epi f).1 (surjective_of_epi_auxs.comp_eq f)),
end
lemma epi_iff_surjective : epi f ↔ function.surjective f :=
⟨λ h, @@surjective_of_epi f h, concrete_category.epi_of_surjective _⟩
lemma epi_iff_range_eq_top : epi f ↔ f.range = ⊤ :=
iff.trans (epi_iff_surjective _) (subgroup.eq_top_iff' f.range).symm
end Group
namespace AddGroup
variables {A B : AddGroup.{u}} (f : A ⟶ B)
lemma epi_iff_surjective : epi f ↔ function.surjective f :=
begin
have i1 : epi f ↔ epi (Group_AddGroup_equivalence.inverse.map f),
{ refine ⟨_, Group_AddGroup_equivalence.inverse.epi_of_epi_map⟩,
introsI e',
apply Group_AddGroup_equivalence.inverse.map_epi },
rwa Group.epi_iff_surjective at i1,
end
lemma epi_iff_range_eq_top : epi f ↔ f.range = ⊤ :=
iff.trans (epi_iff_surjective _) (add_subgroup.eq_top_iff' f.range).symm
end AddGroup
namespace Group
variables {A B : Group.{u}} (f : A ⟶ B)
@[to_additive]
instance forget_Group_preserves_mono : (forget Group).preserves_monomorphisms :=
{ preserves := λ X Y f e, by rwa [mono_iff_injective, ←category_theory.mono_iff_injective] at e }
@[to_additive]
instance forget_Group_preserves_epi : (forget Group).preserves_epimorphisms :=
{ preserves := λ X Y f e, by rwa [epi_iff_surjective, ←category_theory.epi_iff_surjective] at e }
end Group
namespace CommGroup
variables {A B : CommGroup.{u}} (f : A ⟶ B)
@[to_additive AddCommGroup.ker_eq_bot_of_mono]
lemma ker_eq_bot_of_mono [mono f] : f.ker = ⊥ :=
monoid_hom.ker_eq_bot_of_cancel $ λ u v,
(@cancel_mono _ _ _ _ _ f _ (show CommGroup.of f.ker ⟶ A, from u) _).1
@[to_additive AddCommGroup.mono_iff_ker_eq_bot]
lemma mono_iff_ker_eq_bot : mono f ↔ f.ker = ⊥ :=
⟨λ h, @@ker_eq_bot_of_mono f h,
λ h, concrete_category.mono_of_injective _ $ (monoid_hom.ker_eq_bot_iff f).1 h⟩
@[to_additive AddCommGroup.mono_iff_injective]
lemma mono_iff_injective : mono f ↔ function.injective f :=
iff.trans (mono_iff_ker_eq_bot f) $ monoid_hom.ker_eq_bot_iff f
@[to_additive]
lemma range_eq_top_of_epi [epi f] : f.range = ⊤ :=
monoid_hom.range_eq_top_of_cancel $ λ u v h,
(@cancel_epi _ _ _ _ _ f _ (show B ⟶ ⟨B ⧸ monoid_hom.range f⟩, from u) v).1 h
@[to_additive]
lemma epi_iff_range_eq_top : epi f ↔ f.range = ⊤ :=
⟨λ hf, by exactI range_eq_top_of_epi _,
λ hf, concrete_category.epi_of_surjective _ $ monoid_hom.range_top_iff_surjective.mp hf⟩
@[to_additive]
lemma epi_iff_surjective : epi f ↔ function.surjective f :=
by rw [epi_iff_range_eq_top, monoid_hom.range_top_iff_surjective]
@[to_additive]
instance forget_CommGroup_preserves_mono : (forget CommGroup).preserves_monomorphisms :=
{ preserves := λ X Y f e, by rwa [mono_iff_injective, ←category_theory.mono_iff_injective] at e }
@[to_additive]
instance forget_CommGroup_preserves_epi : (forget CommGroup).preserves_epimorphisms :=
{ preserves := λ X Y f e, by rwa [epi_iff_surjective, ←category_theory.epi_iff_surjective] at e }
end CommGroup
end
|
import argparse
import csv
import numpy as np
from BeesEtAl.Base_Optimiser import Base_Optimiser
parser = argparse.ArgumentParser(description="Reload a results file and determine the Pareto-optimal set.")
parser.add_argument('source', help='Specify input file name.', type=str)
parser.add_argument('column', help='Specify one or more column indices (from 0) as costs.', type=int, nargs='+')
parser.add_argument('--out', help='Specify output file name [pareto.csv].', type=str, default='pareto.csv')
parser.add_argument('--save', help='Specify output file name for image [pareto.png].', type=str, default='pareto.png')
args = parser.parse_args()
file_name = args.source
indices = args.column
BO = None
print('Source file: {s}'.format(s=file_name))
with open(file_name, newline='') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
values = np.asarray(list(map(float, row)))
cost = values[indices]
if BO is None:
BO = Base_Optimiser(values, values)
BO.push(cost, values)
BO.pareto(args.out)
if len(indices) > 1:
from BeesEtAl.Base_Plotter import Base_Plotter
BP = Base_Plotter(BO, None)
if len(indices) < 3:
BP.pareto([0, 1])
BP.save(args.save)
BP.sync(10)
else:
BP.pareto([0, 1, 2])
BP.save(args.save)
BP.sync(10)
|
==(a::Node,b::Node)=(a.name==b.name)&(a.presence==b.presence)
nodes(ls::Union{LinkStream,DirectedLinkStream})=ls.V
nodes(ls::Union{LinkStream,DirectedLinkStream},t::Float64)=ls.V
nodes(ls::Union{LinkStream,DirectedLinkStream},t0::Float64,t1::Float64)=ls.V
nodes(s::Union{StreamGraph,DirectedStreamGraph},t::Float64)=[n for (n,interv) in s.W if t ∈ interv]
nodes(s::Union{StreamGraph,DirectedStreamGraph})=[b for (a,b) in s.W]
nodes(s::Union{StreamGraph,DirectedStreamGraph},t0::Float64,t1::Float64)=t0<=t1 ? [n for (n,interv) in s.W if Intervals([(t0,t1)]) ⊆ interv] : []
function nodes(tc::TimeCursor)
length(tc.S.nodes) > 0 && return tc.S.nodes
res=Set{AbstractString}()
if length(tc.S.links) > 0
for l in tc.S.links
push!(res,l[1])
push!(res,l[2])
end
return res
else
return Set{AbstractString}()
end
end
function nodes(tc::TimeCursor,t::Float64)
goto!(tc,t)
if haskey(tc.T,t)
s1=nodes(tc)
previous!(tc)
return s1 ∪ nodes(tc)
else
return nodes(tc)
end
end
function nodes(tc::TimeCursor,t0::Float64,t1::Float64)
N=Set{AbstractString}()
goto!(tc,t0)
haskey(tc.T,t0) && previous!(tc)
N=N ∪ nodes(tc)
while tc.S.t1 < t1
next!(tc)
N=N ∪ nodes(tc)
end
if haskey(tc.T,t1)
next!(tc)
N=N ∪ nodes(tc)
end
N
end
|
module Basic.Types.Gate
%default total
%access public export
|
The imaginary part of a complex number divided by a natural number is equal to the imaginary part of the complex number divided by the natural number. |
FUNCTION:NAME
ioctl:entry
exit_group:entry
-- @@stderr --
dtrace: script 'test/unittest/actions/raise/tst.raise3.d' matched 4 probes
dtrace: allowing destructive actions
|
using Pseudospectra, Test
@testset "Zoom" begin
A = Pseudospectra.grcar(40)
opts = Dict{Symbol,Any}()
ps_data = new_matrix(A,opts)
driver!(ps_data,opts,gs)
zoomin!(gs,ps_data,zkw=1.2+1.8im)
@test ps_data.zoom_pos == 2
# this should return to original portrait
zoomout!(gs,ps_data,zkw=0.0)
@test length(ps_data.zoom_list) == 2
@test ps_data.zoom_pos == 1
# OOB: this should cause a warning:
@test (@test_logs (:warn,r"^unable to zoom") zoomout!(gs,ps_data,zkw=5.0+3.5im)) == -1
zoomout!(gs,ps_data,zkw=0.5+2.0im)
@test ps_data.zoom_pos == 1
@test length(ps_data.zoom_list) == 3
@test all(map(iscomputed,ps_data.zoom_list))
end
|
module Toolkit.System
import System
%default total
export
tryOrDie : Show err
=> Either err type
-> IO type
tryOrDie (Left err) =
do putStrLn "Error Happened"
printLn err
exitFailure
tryOrDie (Right res) = pure res
-- [ EOF ]
|
We hope you can find what you need here. We always effort to show a picture with HD resolution or at least with perfect images. Esstisch Mit Weiser Glasplatte Erstaunlich Moderne Esstische Aus Glas Oder Massivholz Kaufen can be beneficial inspiration for those who seek an image according specific categories; you can find it in this site. Finally all pictures we have been displayed in this site will inspire you all.. |
[STATEMENT]
lemma of_name_inj: "of_name name\<^sub>1 = of_name name\<^sub>2 \<Longrightarrow> name\<^sub>1 = name\<^sub>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. of_name name\<^sub>1 = of_name name\<^sub>2 \<Longrightarrow> name\<^sub>1 = name\<^sub>2
[PROOF STEP]
using bij
[PROOF STATE]
proof (prove)
using this:
bij of_name
goal (1 subgoal):
1. of_name name\<^sub>1 = of_name name\<^sub>2 \<Longrightarrow> name\<^sub>1 = name\<^sub>2
[PROOF STEP]
by (metis to_of_name) |
(* Title: Kleene Algebra
Author: Alasdair Armstrong, Georg Struth, Tjark Weber
Maintainer: Georg Struth <g.struth at sheffield.ac.uk>
Tjark Weber <tjark.weber at it.uu.se>
*)
header {* Models of Dioids *}
theory Dioid_Models
imports Dioid Real
begin
text {* In this section we consider some well known models of
dioids. These so far include the powerset dioid over a monoid,
languages, binary relations, sets of traces, sets paths (in a graph),
as well as the min-plus and the max-plus semirings. Most of these
models are taken from an article about Kleene algebras with
domain~\cite{desharnaismoellerstruth06kad}.
The advantage of formally linking these models with the abstract
axiomatisations of dioids is that all abstract theorems are
automatically available in all models. It therefore makes sense to
establish models for the strongest possible axiomatisations (whereas
theorems should be proved for the weakest ones). *}
subsection {* The Powerset Dioid over a Monoid *}
text {* We assume a multiplicative monoid and define the usual complex
product on sets of elements. We formalise the well known result that
this lifting induces a dioid. *}
instantiation set :: (monoid_mult) monoid_mult
begin
definition one_set_def:
"1 = {1}"
definition c_prod_def: -- "the complex product"
"A \<cdot> B = {u * v | u v. u \<in> A \<and> v \<in> B}"
instance
proof
fix X Y Z :: "'a set"
show "X \<cdot> Y \<cdot> Z = X \<cdot> (Y \<cdot> Z)"
by (auto simp add: c_prod_def) (metis mult.assoc)+
show "1 \<cdot> X = X"
by (simp add: one_set_def c_prod_def)
show "X \<cdot> 1 = X"
by (simp add: one_set_def c_prod_def)
qed
end (* instantiation *)
instantiation set :: (monoid_mult) dioid_one_zero
begin
definition zero_set_def:
"0 = {}"
definition plus_set_def:
"A + B = A \<union> B"
instance
proof
fix X Y Z :: "'a set"
show "X + Y + Z = X + (Y + Z)"
by (simp add: Un_assoc plus_set_def)
show "X + Y = Y + X"
by (simp add: Un_commute plus_set_def)
show "(X + Y) \<cdot> Z = X \<cdot> Z + Y \<cdot> Z"
by (auto simp add: plus_set_def c_prod_def)
show "1 \<cdot> X = X"
by (simp add: one_set_def c_prod_def)
show "X \<cdot> 1 = X"
by (simp add: one_set_def c_prod_def)
show "0 + X = X"
by (simp add: plus_set_def zero_set_def)
show "0 \<cdot> X = 0"
by (simp add: c_prod_def zero_set_def)
show "X \<cdot> 0 = 0"
by (simp add: c_prod_def zero_set_def)
show "X \<subseteq> Y \<longleftrightarrow> X + Y = Y"
by (simp add: plus_set_def subset_Un_eq)
show "X \<subset> Y \<longleftrightarrow> X \<subseteq> Y \<and> X \<noteq> Y"
by (fact psubset_eq)
show "X + X = X"
by (simp add: Un_absorb plus_set_def)
show "X \<cdot> (Y + Z) = X \<cdot> Y + X \<cdot> Z"
by (auto simp add: plus_set_def c_prod_def)
qed
end (* instantiation *)
subsection {* Language Dioids *}
text {* Language dioids arise as special cases of the monoidal lifting
because sets of words form free monoids. Moreover, monoids of words
are isomorphic to monoids of lists under append.
To show that languages form dioids it therefore suffices to show that
sets of lists closed under append and multiplication with the empty
word form a (multiplicative) monoid. Isabelle then does the rest of the work
automatically. Infix~@{text @} denotes word
concatenation. *}
instantiation list :: (type) monoid_mult
begin
definition times_list_def:
"xs * ys \<equiv> xs @ ys"
definition one_list_def:
"1 \<equiv> []"
instance proof
fix xs ys zs :: "'a list"
show "xs * ys * zs = xs * (ys * zs)"
by (simp add: times_list_def)
show "1 * xs = xs"
by (simp add: one_list_def times_list_def)
show "xs * 1 = xs"
by (simp add: one_list_def times_list_def)
qed
end (* instantiation *)
text {* Languages as sets of lists have already been formalised in
Isabelle in various places. We can now obtain much of their algebra
for free. *}
type_synonym 'a lan = "'a list set"
interpretation lan_dioid: dioid_one_zero "op +" "op \<cdot>" "1::'a lan" "0" "op \<subseteq>" "op \<subset>" ..
subsection {* Relation Dioids *}
text {* We now show that binary relations under union, relational
composition, the identity relation, the empty relation and set
inclusion form dioids. Due to the well developed relation library of
Isabelle this is entirely trivial. *}
interpretation rel_dioid: dioid_one_zero "op \<union>" "op O" Id "{}" "op \<subseteq>" "op \<subset>"
by (unfold_locales, auto)
interpretation rel_monoid: monoid_mult Id "op O" ..
subsection {* Trace Dioids *}
text {* Traces have been considered, for instance, by
Kozen~\cite{kozen00hoare} in the context of Kleene algebras with
tests. Intuitively, a trace is an execution sequence of a labelled
transition system from some state to some other state, in which state
labels and action labels alternate, and which begin and end with a
state label.
Traces generalise words: words can be obtained from traces by
forgetting state labels. Similarly, sets of traces generalise
languages.
In this section we show that sets of traces under union, an
appropriately defined notion of complex product, the set of all traces
of length zero, the empty set of traces and set inclusion form a
dioid.
We first define the notion of trace and the product of traces, which
has been called \emph{fusion product} by Kozen. *}
type_synonym ('p, 'a) trace = "'p \<times> ('a \<times> 'p) list"
definition first :: "('p, 'a) trace \<Rightarrow> 'p" where
"first = fst"
lemma first_conv [simp]: "first (p, xs) = p"
by (unfold first_def, simp)
fun last :: "('p, 'a) trace \<Rightarrow> 'p" where
"last (p, []) = p"
| "last (_, xs) = snd (List.last xs)"
lemma last_append [simp]: "last (p, xs @ ys) = last (last (p, xs), ys)"
proof (cases xs)
show "xs = [] \<Longrightarrow> last (p, xs @ ys) = last (last (p, xs), ys)"
by simp
show "\<And>a list. xs = a # list \<Longrightarrow>
last (p, xs @ ys) = last (last (p, xs), ys)"
proof (cases ys)
show "\<And>a list. \<lbrakk>xs = a # list; ys = []\<rbrakk>
\<Longrightarrow> last (p, xs @ ys) = last (last (p, xs), ys)"
by simp
show "\<And>a list aa lista. \<lbrakk>xs = a # list; ys = aa # lista\<rbrakk>
\<Longrightarrow> last (p, xs @ ys) = last (last (p, xs), ys)"
by simp
qed
qed
text {* The fusion product is a partial operation. It is undefined if
the last element of the first trace and the first element of the
second trace are different. If these elements are the same, then the
fusion product removes the first element from the second trace and
appends the resulting object to the first trace. *}
definition t_fusion :: "('p, 'a) trace \<Rightarrow> ('p, 'a) trace \<Rightarrow> ('p, 'a) trace" where
"t_fusion x y \<equiv> if last x = first y then (fst x, snd x @ snd y) else undefined"
text {* We now show that the first element and the last element of a
trace are a left and right unit for that trace and prove some other
auxiliary lemmas. *}
lemma t_fusion_leftneutral [simp]: "t_fusion (first x, []) x = x"
by (cases x, simp add: t_fusion_def)
lemma fusion_rightneutral [simp]: "t_fusion x (last x, []) = x"
by (simp add: t_fusion_def)
lemma first_t_fusion [simp]: "last x = first y \<Longrightarrow> first (t_fusion x y) = first x"
by (simp add: first_def t_fusion_def)
lemma last_t_fusion [simp]: "last x = first y \<Longrightarrow> last (t_fusion x y) = last y"
by (metis (lifting) Dioid_Models.last_append first_def t_fusion_def pair_collapse)
text {* Next we show that fusion of traces is associative. *}
lemma t_fusion_assoc [simp]:
"\<lbrakk> last x = first y; last y = first z \<rbrakk> \<Longrightarrow> t_fusion x (t_fusion y z) = t_fusion (t_fusion x y) z"
by (cases x, cases y, cases z, simp add: t_fusion_def)
subsection {* Sets of Traces *}
text {* We now lift the fusion product to a complex product on sets of
traces. This operation is total. *}
no_notation
times (infixl "\<cdot>" 70)
definition t_prod :: "('p, 'a) trace set \<Rightarrow> ('p, 'a) trace set \<Rightarrow> ('p, 'a) trace set" (infixl "\<cdot>" 70)
where "X \<cdot> Y = {t_fusion u v| u v. u \<in> X \<and> v \<in> Y \<and> last u = first v}"
text {* Next we define the empty set of traces and the set of traces
of length zero as the multiplicative unit of the trace dioid. *}
definition t_zero :: "('p, 'a) trace set" where
"t_zero \<equiv> {}"
definition t_one :: "('p, 'a) trace set" where
"t_one \<equiv> \<Union>p. {(p, [])}"
text {* We now provide elimination rules for trace products.*}
lemma t_prod_iff:
"w \<in> X\<cdot>Y \<longleftrightarrow> (\<exists>u v. w = t_fusion u v \<and> u \<in> X \<and> v \<in> Y \<and> last u = first v)"
by (unfold t_prod_def) auto
lemma t_prod_intro [simp, intro]:
"\<lbrakk> u \<in> X; v \<in> Y; last u = first v \<rbrakk> \<Longrightarrow> t_fusion u v \<in> X\<cdot>Y"
by (metis t_prod_iff)
lemma t_prod_elim [elim]:
"w \<in> X\<cdot>Y \<Longrightarrow> \<exists>u v. w = t_fusion u v \<and> u \<in> X \<and> v \<in> Y \<and> last u = first v"
by (metis t_prod_iff)
text {* Finally we prove the interpretation statement that sets of traces
under union and the complex product based on trace fusion together
with the empty set of traces and the set of traces of length one forms
a dioid. *}
interpretation trace_dioid: dioid_one_zero "op \<union>" t_prod t_one t_zero "op \<subseteq>" "op \<subset>"
apply unfold_locales
apply (auto simp add: t_prod_def t_one_def t_zero_def t_fusion_def)
apply (metis last_append)
apply (metis last_append append_assoc)
done
no_notation
t_prod (infixl "\<cdot>" 70)
subsection {* The Path Diod *}
text {* The next model we consider are sets of paths in a graph. We
consider two variants, one that contains the empty path and one that
doesn't. The former leads to more difficult proofs and a more involved
specification of the complex product. We start with paths that include
the empty path. In this setting, a path is a list of nodes. *}
subsection {* Path Models with the Empty Path *}
type_synonym 'a path = "'a list"
text {* Path fusion is defined similarly to trace
fusion. Mathematically it should be a partial operation. The fusion of
two empty paths yields the empty path; the fusion between a non-empty
path and an empty one is undefined; the fusion of two non-empty paths
appends the tail of the second path to the first one.
We need to use a total alternative and make sure that undefined paths
do not contribute to the complex product. *}
fun p_fusion :: "'a path \<Rightarrow> 'a path \<Rightarrow> 'a path" where
"p_fusion [] _ = []"
| "p_fusion _ [] = []"
| "p_fusion ps (q # qs) = ps @ qs"
lemma p_fusion_assoc:
"p_fusion ps (p_fusion qs rs) = p_fusion (p_fusion ps qs) rs"
proof (induct rs)
case Nil show ?case
by (metis list.exhaust p_fusion.simps(1) p_fusion.simps(2))
case Cons show ?case
proof (induct qs)
case Nil show ?case
by (metis neq_Nil_conv p_fusion.simps(1) p_fusion.simps(2))
case Cons show ?case
by (metis append_Cons append_assoc list.exhaust p_fusion.simps(1) p_fusion.simps(3))
qed
qed
text {* This lemma overapproximates the real situation, but it holds
in all cases where path fusion should be defined. *}
lemma p_fusion_last:
assumes "List.last ps = hd qs"
and "ps \<noteq> []"
and "qs \<noteq> []"
shows "List.last (p_fusion ps qs) = List.last qs"
by (metis (hide_lams, no_types) List.last.simps List.last_append append_Nil2 assms list.sel(1) neq_Nil_conv p_fusion.simps(3))
lemma p_fusion_hd: "\<lbrakk>ps \<noteq> []; qs \<noteq> []\<rbrakk> \<Longrightarrow> hd (p_fusion ps qs) = hd ps"
by (metis list.exhaust p_fusion.simps(3) append_Cons list.sel(1))
lemma nonempty_p_fusion: "\<lbrakk>ps \<noteq> []; qs \<noteq> []\<rbrakk> \<Longrightarrow> p_fusion ps qs \<noteq> []"
by (metis list.exhaust append_Cons p_fusion.simps(3) list.simps(2))
text {* We now define a condition that filters out undefined paths in
the complex product. *}
abbreviation p_filter :: "'a path \<Rightarrow> 'a path \<Rightarrow> bool" where
"p_filter ps qs \<equiv> ((ps = [] \<and> qs = []) \<or> (ps \<noteq> [] \<and> qs \<noteq> [] \<and> (List.last ps) = hd qs))"
no_notation
times (infixl "\<cdot>" 70)
definition p_prod :: "'a path set \<Rightarrow> 'a path set \<Rightarrow> 'a path set" (infixl "\<cdot>" 70)
where "X \<cdot> Y = {rs . \<exists>ps \<in> X. \<exists>qs \<in> Y. rs = p_fusion ps qs \<and> p_filter ps qs}"
lemma p_prod_iff:
"ps \<in> X \<cdot> Y \<longleftrightarrow> (\<exists>qs rs. ps = p_fusion qs rs \<and> qs \<in> X \<and> rs \<in> Y \<and> p_filter qs rs)"
by (unfold p_prod_def) auto
text {* Due to the complexity of the filter condition, proving
properties of complex products can be tedious. *}
lemma p_prod_assoc: "(X \<cdot> Y) \<cdot> Z = X \<cdot> (Y \<cdot> Z)"
proof (rule set_eqI)
fix ps
show "ps \<in> (X \<cdot> Y) \<cdot> Z \<longleftrightarrow> ps \<in> X \<cdot> (Y \<cdot> Z)"
proof (cases ps)
case Nil thus ?thesis
by auto (metis nonempty_p_fusion p_prod_iff)+
next
case Cons thus ?thesis
by (auto simp add: p_prod_iff) (metis (hide_lams, mono_tags) nonempty_p_fusion p_fusion_assoc p_fusion_hd p_fusion_last)+
qed
qed
text {* We now define the multiplicative unit of the path dioid as the
set of all paths of length one, including the empty path, and show the
unit laws with respect to the path product. *}
definition p_one :: "'a path set" where
"p_one \<equiv> {p . \<exists>q::'a. p = [q]} \<union> {[]}"
lemma p_prod_onel [simp]: "p_one \<cdot> X = X"
proof (rule set_eqI)
fix ps
show "ps \<in> p_one \<cdot> X \<longleftrightarrow> ps \<in> X"
proof (cases ps)
case Nil thus ?thesis
by (auto simp add: p_one_def p_prod_def, metis nonempty_p_fusion not_Cons_self)
next
case Cons thus ?thesis
by (auto simp add: p_one_def p_prod_def, metis append_Cons append_Nil list.sel(1) neq_Nil_conv p_fusion.simps(3), metis Cons_eq_appendI list.sel(1) last_ConsL list.simps(3) p_fusion.simps(3) self_append_conv2)
qed
qed
lemma p_prod_oner [simp]: "X \<cdot> p_one = X"
proof (rule set_eqI)
fix ps
show "ps \<in> X \<cdot> p_one \<longleftrightarrow> ps \<in> X"
proof (cases ps)
case Nil thus ?thesis
by (auto simp add: p_one_def p_prod_def, metis nonempty_p_fusion not_Cons_self2, metis p_fusion.simps(1))
next
case Cons thus ?thesis
by (auto simp add: p_one_def p_prod_def, metis append_Nil2 neq_Nil_conv p_fusion.simps(3), metis list.sel(1) list.simps(2) p_fusion.simps(3) self_append_conv)
qed
qed
text {* Next we show distributivity laws at the powerset level. *}
lemma p_prod_distl: "X \<cdot> (Y \<union> Z) = X \<cdot> Y \<union> X \<cdot> Z"
proof (rule set_eqI)
fix ps
show "ps \<in> X \<cdot> (Y \<union> Z) \<longleftrightarrow> ps \<in> X \<cdot> Y \<union> X \<cdot> Z"
by (cases ps) (auto simp add: p_prod_iff)
qed
lemma p_prod_distr: "(X \<union> Y) \<cdot> Z = X \<cdot> Z \<union> Y \<cdot> Z"
proof (rule set_eqI)
fix ps
show "ps \<in> (X \<union> Y) \<cdot> Z \<longleftrightarrow> ps \<in> X \<cdot> Z \<union> Y \<cdot> Z"
by (cases ps) (auto simp add: p_prod_iff)
qed
text {* Finally we show that sets of paths under union, the complex
product, the unit set and the empty set form a dioid. *}
interpretation path_dioid: dioid_one_zero "op \<union>" "op \<cdot>" p_one "{}" "op \<subseteq>" "op \<subset>"
proof
fix x y z :: "'a path set"
show "x \<union> y \<union> z = x \<union> (y \<union> z)"
by auto
show "x \<union> y = y \<union> x"
by auto
show "(x \<cdot> y) \<cdot> z = x \<cdot> (y \<cdot> z)"
by (fact p_prod_assoc)
show "(x \<union> y) \<cdot> z = x \<cdot> z \<union> y \<cdot> z"
by (fact p_prod_distr)
show "p_one \<cdot> x = x"
by (fact p_prod_onel)
show "x \<cdot> p_one = x"
by (fact p_prod_oner)
show "{} \<union> x = x"
by auto
show "{} \<cdot> x = {}"
by (metis all_not_in_conv p_prod_iff)
show "x \<cdot> {} = {}"
by (metis all_not_in_conv p_prod_iff)
show "(x \<subseteq> y) = (x \<union> y = y)"
by auto
show "(x \<subset> y) = (x \<subseteq> y \<and> x \<noteq> y)"
by auto
show "x \<union> x = x"
by auto
show "x \<cdot> (y \<union> z) = x \<cdot> y \<union> x \<cdot> z"
by (metis p_prod_distl)
qed
no_notation
p_prod (infixl "\<cdot>" 70)
subsection {* Path Models without the Empty Path *}
text {* We now build a model of paths that does not include the empty
path and therefore leads to a simpler complex product. *}
datatype 'a ppath = Node 'a | Cons 'a "'a ppath"
primrec pp_first :: "'a ppath \<Rightarrow> 'a" where
"pp_first (Node x) = x"
| "pp_first (Cons x _) = x"
primrec pp_last :: "'a ppath \<Rightarrow> 'a" where
"pp_last (Node x) = x"
| "pp_last (Cons _ xs) = pp_last xs"
text {* The path fusion product (although we define it as a total
funcion) should only be applied when the last element of the first
argument is equal to the first element of the second argument. *}
primrec pp_fusion :: "'a ppath \<Rightarrow> 'a ppath \<Rightarrow> 'a ppath" where
"pp_fusion (Node x) ys = ys"
| "pp_fusion (Cons x xs) ys = Cons x (pp_fusion xs ys)"
text {* We now go through the same steps as for traces and paths
before, showing that the first and last element of a trace a left or
right unit for that trace and that the fusion product on traces is
associative. *}
lemma pp_fusion_leftneutral [simp]: "pp_fusion (Node (pp_first x)) x = x"
by simp
lemma pp_fusion_rightneutral [simp]: "pp_fusion x (Node (pp_last x)) = x"
by (induct x) simp_all
lemma pp_first_pp_fusion [simp]:
"pp_last x = pp_first y \<Longrightarrow> pp_first (pp_fusion x y) = pp_first x"
by (induct x) simp_all
lemma pp_last_pp_fusion [simp]:
"pp_last x = pp_first y \<Longrightarrow> pp_last (pp_fusion x y) = pp_last y"
by (induct x) simp_all
lemma pp_fusion_assoc [simp]:
"\<lbrakk> pp_last x = pp_first y; pp_last y = pp_first z \<rbrakk> \<Longrightarrow> pp_fusion x (pp_fusion y z) = pp_fusion (pp_fusion x y) z"
by (induct x) simp_all
text {* We now lift the path fusion product to a complex product on
sets of paths. This operation is total. *}
definition pp_prod :: "'a ppath set \<Rightarrow> 'a ppath set \<Rightarrow> 'a ppath set" (infixl "\<cdot>" 70)
where "X\<cdot>Y = {pp_fusion u v| u v. u \<in> X \<and> v \<in> Y \<and> pp_last u = pp_first v}"
text {* Next we define the set of paths of length one as the
multiplicative unit of the path dioid. *}
definition pp_one :: "'a ppath set" where
"pp_one \<equiv> range Node"
text {* We again provide an
elimination rule. *}
lemma pp_prod_iff:
"w \<in> X\<cdot>Y \<longleftrightarrow> (\<exists>u v. w = pp_fusion u v \<and> u \<in> X \<and> v \<in> Y \<and> pp_last u = pp_first v)"
by (unfold pp_prod_def) auto
interpretation ppath_dioid: dioid_one_zero "op \<union>" "op \<cdot>" pp_one "{}" "op \<subseteq>" "op \<subset>"
proof
fix x y z :: "'a ppath set"
show "x \<union> y \<union> z = x \<union> (y \<union> z)"
by auto
show "x \<union> y = y \<union> x"
by auto
show "x \<cdot> y \<cdot> z = x \<cdot> (y \<cdot> z)"
by (auto simp add: pp_prod_def, metis pp_first_pp_fusion pp_fusion_assoc, metis pp_last_pp_fusion)
show "(x \<union> y) \<cdot> z = x \<cdot> z \<union> y \<cdot> z"
by (auto simp add: pp_prod_def)
show "pp_one \<cdot> x = x"
by (auto simp add: pp_one_def pp_prod_def, metis pp_fusion.simps(1) pp_last.simps(1) rangeI)
show "x \<cdot> pp_one = x"
by (auto simp add: pp_one_def pp_prod_def, metis pp_first.simps(1) pp_fusion_rightneutral rangeI)
show "{} \<union> x = x"
by auto
show "{} \<cdot> x = {}"
by (simp add: pp_prod_def)
show "x \<cdot> {} = {}"
by (simp add: pp_prod_def)
show "x \<subseteq> y \<longleftrightarrow> x \<union> y = y"
by auto
show "x \<subset> y \<longleftrightarrow> x \<subseteq> y \<and> x \<noteq> y"
by auto
show "x \<union> x = x"
by auto
show "x \<cdot> (y \<union> z) = x \<cdot> y \<union> x \<cdot> z"
by (auto simp add: pp_prod_def)
qed
no_notation
pp_prod (infixl "\<cdot>" 70)
subsection {* The Distributive Lattice Dioid *}
text {* A bounded distributive lattice is a distributive lattice with
a least and a greatest element. Using Isabelle's lattice theory file
we define a bounded distributive lattice as an axiomatic type class
and show, using a sublocale statement, that every bounded distributive
lattice is a dioid with one and zero. *}
class bounded_distributive_lattice = bounded_lattice + distrib_lattice
sublocale bounded_distributive_lattice \<subseteq> dioid_one_zero sup inf top bot less_eq
proof
fix x y z
show "sup (sup x y) z = sup x (sup y z)"
by (fact sup_assoc)
show "sup x y = sup y x"
by (fact sup.commute)
show "inf (inf x y) z = inf x (inf y z)"
by (metis inf.commute inf.left_commute)
show "inf (sup x y) z = sup (inf x z) (inf y z)"
by (fact inf_sup_distrib2)
show "inf top x = x"
by simp
show "inf x top = x"
by simp
show "sup bot x = x"
by simp
show "inf bot x = bot"
by simp
show "inf x bot = bot"
by simp
show "(x \<le> y) = (sup x y = y)"
by (fact le_iff_sup)
show "(x < y) = (x \<le> y \<and> x \<noteq> y)"
by auto
show "sup x x = x"
by simp
show "inf x (sup y z) = sup (inf x y) (inf x z)"
by (fact inf_sup_distrib1)
qed
subsection {* The Boolean Dioid *}
text {* In this section we show that the booleans form a dioid,
because the booleans form a bounded distributive lattice. *}
instantiation bool :: bounded_distributive_lattice
begin
instance ..
end (* instantiation *)
interpretation boolean_dioid: dioid_one_zero sup inf True False less_eq less
by (unfold_locales, simp_all add: inf_bool_def sup_bool_def)
subsection {* The Max-Plus Dioid *}
text {* The following dioids have important applications in
combinatorial optimisations, control theory, algorithm design and
computer networks. *}
text {* A definition of reals extended with~@{text "+\<infinity>"} {\em
and}~@{text "-\<infinity>"} may be found in {\em
HOL/Library/Extended\_Real.thy}. Alas, we require separate extensions
with either~@{text "+\<infinity>"} or~@{text "-\<infinity>"}. *}
text {* The carrier set of the max-plus semiring is the set of real
numbers extended by minus infinity. The operation of addition is
maximum, the operation of multiplication is addition, the additive
unit is minus infinity and the multiplicative unit is zero. *}
datatype mreal = mreal real | MInfty -- "minus infinity"
fun mreal_max where
"mreal_max (mreal x) (mreal y) = mreal (max x y)"
| "mreal_max x MInfty = x"
| "mreal_max MInfty y = y"
lemma mreal_max_simp_3 [simp]: "mreal_max MInfty y = y"
by (cases y, simp_all)
fun mreal_plus where
"mreal_plus (mreal x) (mreal y) = mreal (x + y)"
| "mreal_plus _ _ = MInfty"
text {* We now show that the max plus-semiring satisfies the axioms of
selective semirings, from which it follows that it satisfies the dioid
axioms. *}
instantiation mreal :: selective_semiring
begin
definition zero_mreal_def:
"0 \<equiv> MInfty"
definition one_mreal_def:
"1 \<equiv> mreal 0"
definition plus_mreal_def:
"x + y \<equiv> mreal_max x y"
definition times_mreal_def:
"x * y \<equiv> mreal_plus x y"
definition less_eq_mreal_def:
"(x::mreal) \<le> y \<equiv> x + y = y"
definition less_mreal_def:
"(x::mreal) < y \<equiv> x \<le> y \<and> x \<noteq> y"
instance
proof
fix x y z :: mreal
show "x + y + z = x + (y + z)"
by (cases x, cases y, cases z, simp_all add: plus_mreal_def)
show "x + y = y + x"
by (cases x, cases y, simp_all add: plus_mreal_def)
show "x * y * z = x * (y * z)"
by (cases x, cases y, cases z, simp_all add: times_mreal_def)
show "(x + y) * z = x * z + y * z"
by (cases x, cases y, cases z, simp_all add: plus_mreal_def times_mreal_def)
show "1 * x = x"
by (cases x, simp_all add: one_mreal_def times_mreal_def)
show "x * 1 = x"
by (cases x, simp_all add: one_mreal_def times_mreal_def)
show "0 + x = x"
by (cases x, simp_all add: plus_mreal_def zero_mreal_def)
show "0 * x = 0"
by (cases x, simp_all add: times_mreal_def zero_mreal_def)
show "x * 0 = 0"
by (cases x, simp_all add: times_mreal_def zero_mreal_def)
show "x \<le> y \<longleftrightarrow> x + y = y"
by (metis less_eq_mreal_def)
show "x < y \<longleftrightarrow> x \<le> y \<and> x \<noteq> y"
by (metis less_mreal_def)
show "x + y = x \<or> x + y = y"
by (cases x, cases y, simp_all add: plus_mreal_def, metis linorder_le_cases max.absorb_iff2 max.absorb1)
show "x * (y + z) = x * y + x * z"
by (cases x, cases y, cases z, simp_all add: plus_mreal_def times_mreal_def) qed
end (* instantiation *)
subsection {* The Min-Plus Dioid *}
text {* The min-plus dioid is also known as {\em tropical
semiring}. Here we need to add a positive infinity to the real
numbers. The procedere follows that of max-plus semirings. *}
datatype preal = preal real | PInfty -- "plus infinity"
fun preal_min where
"preal_min (preal x) (preal y) = preal (min x y)"
| "preal_min x PInfty = x"
| "preal_min PInfty y = y"
lemma preal_min_simp_3 [simp]: "preal_min PInfty y = y"
by (cases y, simp_all)
fun preal_plus where
"preal_plus (preal x) (preal y) = preal (x + y)"
| "preal_plus _ _ = PInfty"
instantiation preal :: selective_semiring
begin
definition zero_preal_def:
"0 \<equiv> PInfty"
definition one_preal_def:
"1 \<equiv> preal 0"
definition plus_preal_def:
"x + y \<equiv> preal_min x y"
definition times_preal_def:
"x * y \<equiv> preal_plus x y"
definition less_eq_preal_def:
"(x::preal) \<le> y \<equiv> x + y = y"
definition less_preal_def:
"(x::preal) < y \<equiv> x \<le> y \<and> x \<noteq> y"
instance
proof
fix x y z :: preal
show "x + y + z = x + (y + z)"
by (cases x, cases y, cases z, simp_all add: plus_preal_def)
show "x + y = y + x"
by (cases x, cases y, simp_all add: plus_preal_def)
show "x * y * z = x * (y * z)"
by (cases x, cases y, cases z, simp_all add: times_preal_def)
show "(x + y) * z = x * z + y * z"
by (cases x, cases y, cases z, simp_all add: plus_preal_def times_preal_def)
show "1 * x = x"
by (cases x, simp_all add: one_preal_def times_preal_def)
show "x * 1 = x"
by (cases x, simp_all add: one_preal_def times_preal_def)
show "0 + x = x"
by (cases x, simp_all add: plus_preal_def zero_preal_def)
show "0 * x = 0"
by (cases x, simp_all add: times_preal_def zero_preal_def)
show "x * 0 = 0"
by (cases x, simp_all add: times_preal_def zero_preal_def)
show "x \<le> y \<longleftrightarrow> x + y = y"
by (metis less_eq_preal_def)
show "x < y \<longleftrightarrow> x \<le> y \<and> x \<noteq> y"
by (metis less_preal_def)
show "x + y = x \<or> x + y = y"
by (cases x, cases y, simp_all add: plus_preal_def, metis linorder_le_cases min.absorb2 min.absorb_iff1)
show "x * (y + z) = x * y + x * z"
by (cases x, cases y, cases z, simp_all add: plus_preal_def times_preal_def) qed
end (* instantiation *)
text {* Variants of min-plus and max-plus semirings can easily be
obtained. Here we formalise the min-plus semiring over the natural
numbers as an example. *}
datatype pnat = pnat nat | PInfty -- "plus infinity"
fun pnat_min where
"pnat_min (pnat x) (pnat y) = pnat (min x y)"
| "pnat_min x PInfty = x"
| "pnat_min PInfty x = x"
lemma pnat_min_simp_3 [simp]: "pnat_min PInfty y = y"
by (cases y, simp_all)
fun pnat_plus where
"pnat_plus (pnat x) (pnat y) = pnat (x + y)"
| "pnat_plus _ _ = PInfty"
instantiation pnat :: selective_semiring
begin
definition zero_pnat_def:
"0 \<equiv> PInfty"
definition one_pnat_def:
"1 \<equiv> pnat 0"
definition plus_pnat_def:
"x + y \<equiv> pnat_min x y"
definition times_pnat_def:
"x * y \<equiv> pnat_plus x y"
definition less_eq_pnat_def:
"(x::pnat) \<le> y \<equiv> x + y = y"
definition less_pnat_def:
"(x::pnat) < y \<equiv> x \<le> y \<and> x \<noteq> y"
lemma zero_pnat_top: "(x::pnat) \<le> 1"
by (cases x, simp_all add: less_eq_pnat_def plus_pnat_def one_pnat_def)
instance
proof
fix x y z :: pnat
show "x + y + z = x + (y + z)"
by (cases x, cases y, cases z, simp_all add: plus_pnat_def)
show "x + y = y + x"
by (cases x, cases y, simp_all add: plus_pnat_def)
show "x * y * z = x * (y * z)"
by (cases x, cases y, cases z, simp_all add: times_pnat_def)
show "(x + y) * z = x * z + y * z"
by (cases x, cases y, cases z, simp_all add: plus_pnat_def times_pnat_def)
show "1 * x = x"
by (cases x, simp_all add: one_pnat_def times_pnat_def)
show "x * 1 = x"
by (cases x, simp_all add: one_pnat_def times_pnat_def)
show "0 + x = x"
by (cases x, simp_all add: plus_pnat_def zero_pnat_def)
show "0 * x = 0"
by (cases x, simp_all add: times_pnat_def zero_pnat_def)
show "x * 0 = 0"
by (cases x, simp_all add: times_pnat_def zero_pnat_def)
show "x \<le> y \<longleftrightarrow> x + y = y"
by (metis less_eq_pnat_def)
show "x < y \<longleftrightarrow> x \<le> y \<and> x \<noteq> y"
by (metis less_pnat_def)
show "x + y = x \<or> x + y = y"
by (cases x, cases y, simp_all add: plus_pnat_def, metis linorder_le_cases min.absorb2 min.absorb_iff1)
show "x * (y + z) = x * y + x * z"
by (cases x, cases y, cases z, simp_all add: plus_pnat_def times_pnat_def)
qed
end (* instantiation *)
end
|
Require Import ssr.
Set Implicit Arguments.
Unset Strict Implicit.
Import Prenex Implicits.
(** *** Withzero. *)
(* We include a type for a set with a syntactic zero element.
While this is isomorphic to the option type, having a separate type
makes notations cleaner and makes our intention more clear. *)
Section Withzero.
Variable d : eqType.
Inductive withzero (s : Type) : Type := Zero | Nz (x : s).
(* Definition extract x := match x with Nz y => y | _ => t end. *)
Lemma Nz_inj : forall x y : d, Nz x = Nz y -> x = y.
Proof. congruence. Qed.
Definition eqwithzero (x y : withzero d) :=
match x,y with
| Zero, Zero => true
| Nz x, Nz y => x == y
| _,_ => false
end.
Lemma eqwithzeroPx : reflect_eq eqwithzero.
Proof.
(* {{{ *)
move=> [|x] [|y]; try by [constructor].
case H : (x == y).
rewrite /= H (eqP H).
by left.
rewrite /= H.
right.
move=> [H']; by rewrite H' eq_refl in H.
(* }}} *)
Qed.
Canonical Structure withzeroData := EqType eqwithzeroPx.
End Withzero.
Implicit Arguments Zero [s].
|
module Flexidisc.TaggedValue
%default total
infixl 8 :=
public export
data TaggedValue : (key : k) -> (v : Type) -> Type where
(:=) : (key : k) -> v -> TaggedValue key v
|
(* Title: HOL/Auth/n_german_lemma_on_inv__18.thy
Author: Yongjian Li and Kaiqiang Duan, State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences
Copyright 2016 State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences
*)
header{*The n_german Protocol Case Study*}
theory n_german_lemma_on_inv__18 imports n_german_base
begin
section{*All lemmas on causal relation between inv__18 and some rule r*}
lemma n_SendInv__part__0Vsinv__18:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInv__part__0 i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendInv__part__0 i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__18 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_SendInv__part__1Vsinv__18:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInv__part__1 i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendInv__part__1 i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__18 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_SendInvAckVsinv__18:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendInvAck i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendInvAck i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__18 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_RecvInvAckVsinv__18:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvInvAck i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_RecvInvAck i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__18 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_SendGntSVsinv__18:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendGntS i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendGntS i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__18 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_SendGntEVsinv__18:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_SendGntE N i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_SendGntE N i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__18 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P3 s"
apply (cut_tac a1 a2 b1, simp, rule_tac x="(neg (andForm (eqn (IVar (Field (Para (Ident ''Chan3'') p__Inv2) ''Cmd'')) (Const InvAck)) (eqn (IVar (Para (Ident ''ShrSet'') p__Inv2)) (Const false))))" in exI, auto) done
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_RecvGntSVsinv__18:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntS i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_RecvGntS i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__18 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_RecvGntEVsinv__18:
assumes a1: "(\<exists> i. i\<le>N\<and>r=n_RecvGntE i)" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s")
proof -
from a1 obtain i where a1:"i\<le>N\<and>r=n_RecvGntE i" apply fastforce done
from a2 obtain p__Inv2 where a2:"p__Inv2\<le>N\<and>f=inv__18 p__Inv2" apply fastforce done
have "(i=p__Inv2)\<or>(i~=p__Inv2)" apply (cut_tac a1 a2, auto) done
moreover {
assume b1: "(i=p__Inv2)"
have "?P1 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
moreover {
assume b1: "(i~=p__Inv2)"
have "?P2 s"
proof(cut_tac a1 a2 b1, auto) qed
then have "invHoldForRule s f r (invariants N)" by auto
}
ultimately show "invHoldForRule s f r (invariants N)" by satx
qed
lemma n_SendReqE__part__1Vsinv__18:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_SendReqE__part__1 i" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_StoreVsinv__18:
assumes a1: "\<exists> i d. i\<le>N\<and>d\<le>N\<and>r=n_Store i d" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_RecvReqEVsinv__18:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_RecvReqE N i" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_SendReqE__part__0Vsinv__18:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_SendReqE__part__0 i" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_SendReqSVsinv__18:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_SendReqS i" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
lemma n_RecvReqSVsinv__18:
assumes a1: "\<exists> i. i\<le>N\<and>r=n_RecvReqS N i" and
a2: "(\<exists> p__Inv2. p__Inv2\<le>N\<and>f=inv__18 p__Inv2)"
shows "invHoldForRule s f r (invariants N)"
apply (rule noEffectOnRule, cut_tac a1 a2, auto) done
end
|
= = = Colleges and universities = = =
|
#include <NTL/vec_xdouble.h>
#include <NTL/new.h>
NTL_START_IMPL
NTL_vector_impl(xdouble,vec_xdouble)
NTL_io_vector_impl(xdouble,vec_xdouble)
NTL_eq_vector_impl(xdouble,vec_xdouble)
NTL_END_IMPL
|
[STATEMENT]
lemma Inf_insert:
fixes S :: "real set"
shows "bounded S \<Longrightarrow> Inf (insert x S) = (if S = {} then x else min x (Inf S))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. bounded S \<Longrightarrow> Inf (insert x S) = (if S = {} then x else min x (Inf S))
[PROOF STEP]
by (auto simp: bounded_imp_bdd_below inf_min cInf_insert_If) |
import data.set.lattice
import data.set.function
import analysis.special_functions.log.basic
section
variables {α β : Type*}
variable f : α → β
variables s t : set α
variables u v : set β
open function
open set
example : f ⁻¹' (u ∩ v) = f ⁻¹' u ∩ f ⁻¹' v :=
by { ext, refl }
example : f '' (s ∪ t) = f '' s ∪ f '' t :=
begin
ext y, split,
{ rintros ⟨x, xs | xt, rfl⟩,
{ left, use [x, xs],},
{ right, use [x, xt]},},
{ rintros (⟨x, xs, rfl⟩ | ⟨x, xt, rfl⟩),
{ use [x, or.inl xs]},
{ use [x, or.inr xt]}},
end
example : f '' s ⊆ v ↔ s ⊆ f ⁻¹' v :=
begin
split,
{ rintros fsv x xs,
apply fsv,
use [x, xs, rfl],},
{ rintros sfv y ⟨x, xs, rfl⟩,
apply sfv,
from xs,},
end
#check image_subset_iff
example (h : injective f) : f ⁻¹' (f '' s) ⊆ s :=
begin
rintros y ⟨x, ⟨xs, heq⟩⟩,
rw h heq at xs,
from xs,
end
#check injective f
#check surjective f
example : f '' (f⁻¹' u) ⊆ u :=
begin
refine image_subset_iff.mpr _,
apply subset.refl,
end
example (h : surjective f) : u ⊆ f '' (f⁻¹' u) :=
begin
rintros y yu,
rcases h y with ⟨x, rfl⟩,
use x,
split,
from yu,
refl,
end
example (h : s ⊆ t) : f '' s ⊆ f '' t :=
begin
rintros y ⟨x, ⟨xs, fxeq⟩⟩,
use [x, h xs, fxeq],
end
example (h : u ⊆ v) : f ⁻¹' u ⊆ f ⁻¹' v :=
begin
intros x xu,
apply h,
from xu,
end
example : f ⁻¹' (u ∪ v) = f ⁻¹' u ∪ f ⁻¹' v :=
begin
ext x,
split,
{ rintro (fu | fv),
left, from fu,
right, from fv,},
{ rintro (fu | fv),
left, from fu,
right, from fv,}
end
example : f '' (s ∩ t) ⊆ f '' s ∩ f '' t :=
begin
rintros y ⟨x, ⟨⟨xs, xt⟩, fxeq⟩⟩,
split,
{ use [x, xs, fxeq]},
{ use [x, xt, fxeq]},
end
example (h : injective f) : f '' s ∩ f '' t ⊆ f '' (s ∩ t) :=
begin
rintros y ⟨⟨x, ⟨xs, fxeq⟩⟩, ⟨z, ⟨zt, fzeq⟩⟩⟩,
use x,
split,
{ split, from xs,
have : x = z,
apply h,
apply eq.trans fxeq fzeq.symm,
rwa this.symm at zt,},
{ from fxeq,},
end
example : f '' s \ f '' t ⊆ f '' (s \ t) :=
begin
rintros y ⟨fs, fnt⟩,
rcases fs with ⟨x, ⟨xs, fxeq⟩⟩,
use x,
split,
{ split,
from xs,
contrapose! fnt,
use [x, fnt, fxeq],},
{ from fxeq,},
end
example : f ⁻¹' u \ f ⁻¹' v ⊆ f ⁻¹' (u \ v) :=
begin
rintros x ⟨xu, xnv⟩,
split; assumption,
end
example : f '' s ∩ v = f '' (s ∩ f ⁻¹' v) :=
begin
ext y,
split,
{ rintros ⟨⟨x, ⟨xs, fxeq⟩⟩, yv⟩,
use x,
split,
{ split,
from xs,
rwa fxeq.symm at yv,},
{ from fxeq,}},
{ rintros ⟨x, ⟨⟨xs, yv⟩, fxeq⟩⟩,
use x,
from ⟨xs, fxeq⟩,
rwa fxeq.symm,}
end
example : f '' (s ∩ f ⁻¹' u) ⊆ f '' s ∪ u :=
begin
rintros y ⟨x, ⟨xs, yu⟩, fxeq⟩,
left,
use [x, xs, fxeq],
end
example : s ∩ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∩ u) :=
begin
rintros x ⟨xs, fxu⟩,
split,
{ use [x, xs, rfl],},
{ from fxu,}
end
example : s ∪ f ⁻¹' u ⊆ f ⁻¹' (f '' s ∪ u) :=
begin
rintros x (xs | fxu),
{ left,
use [x, xs, rfl],},
{ right,
use fxu,}
end
variables {I : Type*} (A : I → set α) (B : I → set β)
example : f '' (⋃ i, A i) = ⋃ i, f '' A i :=
begin
ext y, simp,
split,
{ rintros ⟨x, ⟨i, xAi⟩, fxeq⟩,
use [i, x, xAi, fxeq],},
{ rintros ⟨i, x, ⟨xAi, fxeq⟩⟩,
use [x, i, xAi, fxeq],},
end
example : f '' (⋂ i, A i) ⊆ ⋂ i, f '' A i :=
begin
intro y, simp,
intros x h fxeq i,
use [x, h i, fxeq],
end
example (i : I) (injf : injective f) :
(⋂ i, f '' A i) ⊆ f '' (⋂ i, A i) :=
begin
intro y, simp,
intro h,
rcases h i with ⟨x, ⟨xAi, fxeq⟩⟩,
use x, split,
{ intro i',
rcases h i' with ⟨x', x'Ai, fx'eq⟩,
have : f x = f x', by rw [fxeq, fx'eq],
have : x = x', from injf this,
rwa this,},
{ from fxeq,},
end
end
section
open set real
example : inj_on log { x | x > 0 } :=
begin
intros x xpos y ypos e,
calc
x = exp (log x) : by rw exp_log xpos
... = exp (log y) : by rw e
... = y : by rw exp_log ypos,
end
example : range exp = { y | y > 0 } :=
begin
ext y, split,
{ rintros ⟨x, rfl⟩,
apply exp_pos,},
{ intro ypos,
use log y,
apply exp_log ypos,}
end
example : inj_on sqrt { x | x ≥ 0 } :=
begin
intros x xge y yge e,
calc
x = (sqrt x) ^ 2 : by rw sq_sqrt xge
... = (sqrt y) ^ 2 : by rw e
... = y : by rw sq_sqrt yge,
end
#check sqrt_sq
example : inj_on (λ x, x^2) { x : ℝ | x ≥ 0 } :=
begin
intros x xge y yge,
dsimp, intro e,
calc
x = sqrt (x ^ 2) : by rw sqrt_sq xge
... = sqrt (y ^ 2) : by rw e
... = y : by rw sqrt_sq yge,
end
example : sqrt '' { x | x ≥ 0 } = {y | y ≥ 0} :=
begin
ext y, dsimp, split,
{ rintro ⟨x, xge, fxeq⟩,
rw ←fxeq,
apply sqrt_nonneg,},
{ intro yge,
use y^2,
dsimp,
split,
apply sq_nonneg,
rw sqrt_sq yge,}
end
example : range (λ x, x^2) = {y : ℝ | y ≥ 0} :=
begin
ext y, split,
{ rintro ⟨x, fxeq⟩,
dsimp at fxeq,
dsimp, rw ←fxeq,
apply sq_nonneg,},
{ dsimp, intro yge,
use sqrt y,
dsimp,
rw sq_sqrt yge,},
end
end
section
variables {α β : Type*} [inhabited α]
#check (default : α)
variables (P : α → Prop) (h : ∃ x, P x)
#check classical.some h
example : P (classical.some h) := classical.some_spec h
noncomputable theory
open_locale classical
def inverse (f : α → β) : β → α :=
λ y : β, if h : ∃ x, f x = y then classical.some h else default
theorem inverse_spec {f : α → β} (y : β) (h : ∃ x, f x = y) :
f (inverse f y) = y :=
begin
rw inverse, dsimp, rw dif_pos h,
exact classical.some_spec h
end
variable f : α → β
open function
example : injective f ↔ left_inverse (inverse f) f :=
begin
split,
{ intros injf x,
apply injf,
apply inverse_spec,
use x,},
{ intros lfi x y e,
calc
x = inverse f (f x) : by rw lfi
... = inverse f (f y) : by rw e
... = y : by rw lfi,},
end
example : surjective f ↔ right_inverse (inverse f) f :=
begin
split,
{ intros surf y,
apply inverse_spec,
use surf y,},
{ rintros rfi y,
use (inverse f) y,
from rfi y,}
end
theorem Cantor : ∀ f : α → set α, ¬ surjective f :=
begin
intros f surf,
let S := { i | i ∉ f i},
rcases surf S with ⟨j, h⟩,
have h₁ : j ∉ f j,
intro h',
have : j ∉ f j,
by rwa h at h',
contradiction,
have h₂ : j ∈ S,
from h₁,
have h₃ : j ∉ S,
rwa h at h₁,
contradiction,
end
end
|
/-
Copyright (c) 2021 Vladimir Goryachev. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies, Vladimir Goryachev, Kyle Miller, Scott Morrison, Eric Rodriguez
-/
import data.list.basic
import data.nat.prime
import set_theory.fincard
/-!
# Counting on ℕ
This file defines the `count` function, which gives, for any predicate on the natural numbers,
"how many numbers under `k` satisfy this predicate?".
We then prove several expected lemmas about `count`, relating it to the cardinality of other
objects, and helping to evaluate it for specific `k`.
-/
open finset
namespace nat
variable (p : ℕ → Prop)
section count
variable [decidable_pred p]
/-- Count the number of naturals `k < n` satisfying `p k`. -/
def count (n : ℕ) : ℕ := (list.range n).countp p
@[simp] lemma count_zero : count p 0 = 0 :=
by rw [count, list.range_zero, list.countp]
/-- A fintype instance for the set relevant to `nat.count`. Locally an instance in locale `count` -/
def count_set.fintype (n : ℕ) : fintype {i // i < n ∧ p i} :=
begin
apply fintype.of_finset ((finset.range n).filter p),
intro x,
rw [mem_filter, mem_range],
refl,
end
localized "attribute [instance] nat.count_set.fintype" in count
lemma count_eq_card_filter_range (n : ℕ) : count p n = ((range n).filter p).card :=
by { rw [count, list.countp_eq_length_filter], refl, }
/-- `count p n` can be expressed as the cardinality of `{k // k < n ∧ p k}`. -/
lemma count_eq_card_fintype (n : ℕ) : count p n = fintype.card {k : ℕ // k < n ∧ p k} :=
by { rw [count_eq_card_filter_range, ←fintype.card_of_finset, ←count_set.fintype], refl, }
lemma count_succ (n : ℕ) : count p (n + 1) = count p n + (if p n then 1 else 0) :=
by split_ifs; simp [count, list.range_succ, h]
@[mono] lemma count_monotone : monotone (count p) :=
monotone_nat_of_le_succ $ λ n, by by_cases h : p n; simp [count_succ, h]
lemma count_add (a b : ℕ) : count p (a + b) = count p a + count (λ k, p (a + k)) b :=
begin
have : disjoint ((range a).filter p) (((range b).map $ add_left_embedding a).filter p),
{ intros x hx,
simp_rw [inf_eq_inter, mem_inter, mem_filter, mem_map, mem_range] at hx,
obtain ⟨⟨hx, _⟩, ⟨c, _, rfl⟩, _⟩ := hx,
exact (self_le_add_right _ _).not_lt hx },
simp_rw [count_eq_card_filter_range, range_add, filter_union, card_disjoint_union this,
map_filter, add_left_embedding, card_map], refl,
end
lemma count_add' (a b : ℕ) : count p (a + b) = count (λ k, p (k + b)) a + count p b :=
by { rw [add_comm, count_add, add_comm], simp_rw [add_comm b] }
lemma count_one : count p 1 = if p 0 then 1 else 0 := by simp [count_succ]
lemma count_succ' (n : ℕ) : count p (n + 1) = count (λ k, p (k + 1)) n + if p 0 then 1 else 0 :=
by rw [count_add', count_one]
variables {p}
@[simp] lemma count_lt_count_succ_iff {n : ℕ} : count p n < count p (n + 1) ↔ p n :=
by by_cases h : p n; simp [count_succ, h]
lemma count_succ_eq_succ_count_iff {n : ℕ} : count p (n + 1) = count p n + 1 ↔ p n :=
by by_cases h : p n; simp [h, count_succ]
lemma count_succ_eq_count_iff {n : ℕ} : count p (n + 1) = count p n ↔ ¬p n :=
by by_cases h : p n; simp [h, count_succ]
alias count_succ_eq_succ_count_iff ↔ _ count_succ_eq_succ_count
alias count_succ_eq_count_iff ↔ _ count_succ_eq_count
lemma count_le_cardinal (n : ℕ) : (count p n : cardinal) ≤ cardinal.mk {k | p k} :=
begin
rw [count_eq_card_fintype, ← cardinal.mk_fintype],
exact cardinal.mk_subtype_mono (λ x hx, hx.2),
end
lemma lt_of_count_lt_count {a b : ℕ} (h : count p a < count p b) : a < b :=
(count_monotone p).reflect_lt h
lemma count_strict_mono {m n : ℕ} (hm : p m) (hmn : m < n) : count p m < count p n :=
(count_lt_count_succ_iff.2 hm).trans_le $ count_monotone _ (nat.succ_le_iff.2 hmn)
lemma count_injective {m n : ℕ} (hm : p m) (hn : p n) (heq : count p m = count p n) : m = n :=
begin
by_contra,
wlog hmn : m < n,
{ exact ne.lt_or_lt h },
{ simpa [heq] using count_strict_mono hm hmn }
end
lemma count_le_card (hp : (set_of p).finite) (n : ℕ) : count p n ≤ hp.to_finset.card :=
begin
rw count_eq_card_filter_range,
exact finset.card_mono (λ x hx, hp.mem_to_finset.2 (mem_filter.1 hx).2)
end
lemma count_lt_card {n : ℕ} (hp : (set_of p).finite) (hpn : p n) :
count p n < hp.to_finset.card :=
(count_lt_count_succ_iff.2 hpn).trans_le (count_le_card hp _)
variable {q : ℕ → Prop}
variable [decidable_pred q]
end count
end nat
|
-- Occurs when different mixfix operators use similar names.
module Issue147a where
postulate
X : Set
f : X -> X
f_ : X -> X
bad : X -> X
bad x = f x
|
(*-------------------------------------------*
| CSP-Prover on Isabelle2004 |
| December 2004 |
| August 2005 (modified) |
| |
| CSP-Prover on Isabelle2005 |
| October 2005 (modified) |
| April 2006 (modified) |
| |
| CSP-Prover on Isabelle2009-2 |
| October 2010 (modified) |
| |
| Yoshinao Isobe (AIST JAPAN) |
*-------------------------------------------*)
theory Set_F_cpo
imports Set_F CPO
begin
(*****************************************************************
1. Set_F is a pointed cpo.
2.
3.
4.
*****************************************************************)
(* The following simplification rules are deleted in this theory file *)
(* because they unexpectly rewrite UnionT and InterT. *)
(* Union (B ` A) = (UN x:A. B x) *)
(* Inter (B ` A) = (INT x:A. B x) *)
(*
declare Union_image_eq [simp del]
declare Inter_image_eq [simp del]
*)
declare Sup_image_eq [simp del]
declare Inf_image_eq [simp del]
(*********************************************************
Bottom in Set_T
*********************************************************)
(*
instance setF :: (type) bot0
by (intro_classes)
*)
instantiation setF :: (type) bot0
begin
definition
bottom_setF_def : "Bot == {}f"
instance ..
end
(*
defs (overloaded)
bottom_setF_def : "Bot == {}f"
*)
lemma bottom_setF : "ALL (F::'a setF). Bot <= F"
by (simp add: bottom_setF_def)
instance setF :: (type) bot
apply (intro_classes)
by (simp add: bottom_setF)
(**********************************************************
lemmas used in a proof that set_F is a cpo.
**********************************************************)
(* UnionF Fs is an upper bound of Fs *)
lemma UnionF_isUB : "(UnionF Fs) isUB Fs"
apply (simp add: isUB_def)
apply (simp add: subsetF_iff)
apply (intro allI impI)
apply (rule_tac x=y in bexI)
by (auto)
(* UnionF Fs is the least upper bound of Fs *)
lemma UnionF_isLUB : "UnionF Fs isLUB Fs"
apply (simp add: isLUB_def UnionF_isUB)
apply (simp add: isUB_def)
apply (simp add: subsetF_iff)
apply (intro allI impI)
apply (erule bexE)
apply (drule_tac x="F" in spec)
by (simp)
(* the least upper bound of Fs is UnionF Fs *)
lemma isLUB_UnionF_only_if: "F isLUB Fs ==> F = UnionF Fs"
apply (insert UnionF_isLUB[of Fs])
apply (rule LUB_unique)
by (simp_all)
(* iff *)
lemma isLUB_UnionF : "(F isLUB Fs) = (F = UnionF Fs)"
apply (rule iffI)
apply (simp add: isLUB_UnionF_only_if)
apply (simp add: UnionF_isLUB)
done
(* LUB is UnionF Fs *)
lemma LUB_UnionF : "LUB Fs = UnionF Fs"
by (simp add: isLUB_LUB UnionF_isLUB)
(**********************************************************
( setF, <= ) is a CPO
**********************************************************)
instance setF :: (type) cpo
apply (intro_classes)
apply (simp add: hasLUB_def)
apply (rule_tac x="UnionF X" in exI)
apply (simp add: directed_def UnionF_isLUB)
done
(**********************************************************
( setF, <= ) is a pointed CPO
**********************************************************)
instance setF :: (type) cpo_bot
by (intro_classes)
(****************** to add them again ******************)
(*
declare Union_image_eq [simp]
declare Inter_image_eq [simp]
*)
declare Sup_image_eq [simp]
declare Inf_image_eq [simp]
end
|
`is_element/ICP_alt` := (N::posint) -> (A::set) -> proc(Ru)
local n,R,u;
global reason;
n := nops(A);
if n = 0 then
reason := [convert(procname,string),"A is empty"];
return false;
fi;
if not(type(Ru,list) and nops(Ru) = 2) then
reason := [convert(procname,string),"Ru is not a list of length two"];
return false;
fi;
R,u := op(Ru);
if not `is_element/ord`(A)(R) then
reason := [convert(procname,string),"R is not an order on A",reason];
return false;
fi;
if not(type(u,list(posint)) and
nops(u) = n-1 and
max(op(u)) <= N) then
reason := [convert(procname,string),"u is not in [1,N]^(n-1)"];
return false;
fi;
return true;
end:
`is_equal/ICP_alt` := (N::posint) -> (A::set) -> proc(Ru1,Ru2)
global reason;
if Ru1 <> Ru2 then
reason := [convert(procname,string),"Ru1 <> Ru2",Ru1,Ru2];
return false;
fi;
return true;
end:
`list_elements/ICP_alt` := (N::posint) -> proc(A::set)
local RR,uu,n,R,u,i;
RR := `list_elements/ord`(A);
n := nops(A);
uu := [[]];
for i from 1 to n-1 do
uu := [seq(seq([op(u),i],i=1..N),u in uu)];
od:
return [seq(seq([R,u],u in uu),R in RR)];
end:
`random_element/ICP_alt` := (N::posint) -> (A::set) -> proc()
local R,u,i;
R := `random_element/ord`(A)();
u := [seq(rand(1..N)(),i=1..nops(A)-1)];
return [R,u];
end:
`count_elements/ICP_alt` := (N::posint) -> proc(A::set)
local n;
n := nops(A);
return n! * N^(n-1);
end:
|
library(changepoint)
library(dplyr)
library(ggplot2)
air_data <- readRDS("C:/Users/anthony/Desktop/my_project/census-app/data/Air_box.rds")
PM25_of_sensor <- subset(air_data, ID == sensor_ID[13])
del_index_arr = group_by(PM25_of_sensor, as.Date(f_time, tz = "Etc/GMT+8")) %>%
summarise( length(PM25) > 4 ) #change point detection is not available when length is shorter than 4
Day_ID <- unique(as.Date(PM25_of_sensor$f_time, tz = "Etc/GMT+8"))
del_index = which(as.data.frame(del_index_arr[,2])[,1] %in% 0)
if(length(del_index) != 0) PM25_of_sensor <- PM25_of_sensor[ -which( Day_ID[del_index] == as.Date(PM25_of_sensor$f_time, tz = "Etc/GMT+8") ),]
#get Day_ID after deleting the ones with length shorter than 4
Day_ID <- unique(as.Date(PM25_of_sensor$f_time, tz = "Etc/GMT+8"))
sen_of_day <- PM25_of_sensor[which(as.Date(PM25_of_sensor$f_time, tz = "Etc/GMT+8") == Day_ID[1]),]
#ch_id_group = group_by(PM25_of_sensor, as.Date(f_time, tz = "Etc/GMT+8")) %>%
# summarise(ifelse(length( cpts( cpt.meanvar(PM25) ) ) == 0, NA, cpts( cpt.meanvar(PM25) ) ))
amoc <- cpt.meanvar(PM25_of_sensor$PM25, method = "AMOC") #call by cpts(amoc)
pelt <- cpt.meanvar(PM25_of_sensor$PM25, method = "PELT") #call by cpts(pelt)
segneigh <- cpt.meanvar(PM25_of_sensor$PM25,penalty="Asymptotic",pen.value=0.01,method="SegNeigh",Q=5,class=FALSE)
binseg <- cpt.meanvar(PM25_of_sensor$PM25,penalty="Manual",pen.value="4*log(n)",method="BinSeg",Q=5,class=FALSE)
#other try
pelt_1 <- cpt.meanvar(sen_of_day$PM25, pen.value = c(4,1500), penalty = "CROPS", method = "PELT") #call by cpts(pelt)
cpts.full(pelt_1)
cpt.out(pelt_1)
plot(pelt_1,ncpts = 5)
apply([email protected], 2, function(x) length(which(!is.na(x))))
#print pelt
p <- ggplot(PM25_of_sensor,
aes(x = as.POSIXct(f_time, tz = "Etc/GMT+8"), y = PM25)) +
geom_line() + geom_vline(xintercept = as.numeric(PM25_of_sensor$f_time[ cpts(pelt_1) ]), colour = "red")
print(p)
#print SegNeigh
p <- ggplot(PM25_of_sensor,
aes(x = as.POSIXct(f_time, tz = "Etc/GMT+8"), y = PM25)) +
geom_line() + geom_vline(xintercept = as.numeric(PM25_of_sensor$f_time[ segneigh ]), colour = "red")
print(p)
#print BinSeg
p <- ggplot(PM25_of_sensor,
aes(x = as.POSIXct(f_time, tz = "Etc/GMT+8"), y = PM25)) +
geom_line() + geom_vline(xintercept = as.numeric(PM25_of_sensor$f_time[ cpts(pelt_1) ]), colour = "red")
print(p)
|
{-# OPTIONS --without-K --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Substitution.Introductions {{eqrel : EqRelSet}} where
open import Definition.LogicalRelation.Substitution.Introductions.Application public
open import Definition.LogicalRelation.Substitution.Introductions.Lambda public
open import Definition.LogicalRelation.Substitution.Introductions.Nat public
open import Definition.LogicalRelation.Substitution.Introductions.Natrec public
open import Definition.LogicalRelation.Substitution.Introductions.Pi public
open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst public
open import Definition.LogicalRelation.Substitution.Introductions.Universe public
|
[STATEMENT]
lemma cardinal_le_lepoll: "vcard A \<le> \<alpha> \<Longrightarrow> elts A \<lesssim> elts \<alpha>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. vcard A \<le> \<alpha> \<Longrightarrow> elts A \<lesssim> elts \<alpha>
[PROOF STEP]
by (meson cardinal_eqpoll eqpoll_sym lepoll_trans1 less_eq_V_def subset_imp_lepoll) |
(** Braided monoidal precategories.
Authors: Mario Román, based on a previous implementation by Anthony Bordg.
References: https://ncatlab.org/nlab/show/braided+monoidal+category#the_coherence_laws
**)
(** ** Contents:
- braidings
- hexagon equations
- braided monoidal categories
- accessors
*)
Require Import UniMath.Foundations.PartD.
Require Import UniMath.CategoryTheory.Core.Categories.
Require Import UniMath.CategoryTheory.Core.NaturalTransformations.
Require Import UniMath.CategoryTheory.Core.Functors.
Require Import UniMath.CategoryTheory.PrecategoryBinProduct.
Require Import UniMath.CategoryTheory.Monoidal.AlternativeDefinitions.MonoidalCategoriesTensored.
Local Open Scope cat.
(** * Braidings *)
Section Braiding.
(** In this section, fix a monoidal category. *)
Context (MonM : monoidal_cat).
Local Definition tensor := monoidal_cat_tensor MonM.
Local Definition α := monoidal_cat_associator MonM.
Notation "X ⊗ Y" := (tensor (X, Y)).
Notation "f #⊗ g" := (#tensor (f #, g)) (at level 31).
(* A braiding is a natural isomorphism from (- ⊗ =) to (= ⊗ -). *)
Definition braiding : UU := nat_z_iso tensor (binswap_pair_functor ∙ tensor).
(** * Hexagon equations. *)
Section HexagonEquations.
Context (braid : braiding).
Local Definition γ := pr1 braid.
Local Definition α₁ := pr1 α.
Local Definition α₂ := pr1 (nat_z_iso_inv α).
Definition first_hexagon_eq : UU :=
∏ (a b c : MonM) ,
(α₁ ((a , b) , c)) · (γ (a , (b ⊗ c))) · (α₁ ((b , c) , a)) =
(γ (a , b) #⊗ (id c)) · (α₁ ((b , a) , c)) · ((id b) #⊗ γ (a , c)).
Definition second_hexagon_eq : UU :=
∏ (a b c : MonM) ,
α₂ ((a , b) , c) · (γ (a ⊗ b , c)) · α₂ ((c , a) , b) =
((id a) #⊗ γ (b , c)) · α₂ ((a , c) , b) · (γ (a , c) #⊗ (id b)).
End HexagonEquations.
End Braiding.
(** * Braided monoidal categories *)
Definition braided_monoidal_cat : UU :=
∑ M : monoidal_cat ,
∑ γ : braiding M ,
(first_hexagon_eq M γ) × (second_hexagon_eq M γ).
(** ** Accessors *)
Section Braided_Monoidal_Cat_Acessors.
Context (M : braided_monoidal_cat).
Definition braided_monoidal_cat_monoidal_cat := pr1 M.
Definition braided_monoidal_cat_braiding := pr1 (pr2 M).
Definition braided_monoidal_cat_first_hexagon_eq := pr1 (pr2 (pr2 M)).
Definition braided_monoidal_cat_second_hexagon_eq := pr2 (pr2 (pr2 M)).
End Braided_Monoidal_Cat_Acessors.
Coercion braided_monoidal_cat_monoidal_cat : braided_monoidal_cat >-> monoidal_cat.
|
export RedisString
struct RedisString <: AbstractRedisCollection
conn::AbstractRedisConnection
key::String
end
RedisString(key) = RedisString(default_connection, key)
function getindex(rs::RedisString, x::Integer, y::Integer)
# it is always not null: non-exist keys are treated as empty string by redis
exec(rs.conn, "getrange", rs.key, zero_index(x), zero_index(y)) |> String
end
function getindex(rs::RedisString, x::UnitRange{T}) where T<:Integer
rs[x.start, x.stop]
end
function getindex(rs::RedisString, x::Integer) # do we really need this?
rs[x, x][1]
end
function getindex(rs::RedisString, ::Colon=Colon())
String(@some(exec(rs.conn, "get", rs.key)))
end
function setindex!(rs::RedisString, value, offset::Integer)
exec(rs.conn, "setrange", rs.key, zero_index(offset), value)
rs
end
function setindex!(rs::RedisString, value, x::UnitRange{T}) where T<:Integer
value = value |> string |> String
x.stop - x.start + 1 == sizeof(value) || throw(DimensionMismatch())
rs[x.start] = value
rs
end
function setindex!(rs::RedisString, value, ::Colon=Colon())
exec(rs.conn, "set", rs.key, value)
rs
end
"this methods should always be used in the form of `rs += xx`"
function (+)(rs::RedisString, value)
exec(rs.conn, "append", rs.key, value)
rs
end
"NOTE: Redis count length by byte, while julia count by char"
function length(rs::RedisString)
exec(rs.conn, "strlen", rs.key)::Int64
end
function lastindex(rs::RedisString)
length(rs)
end
function string(rs::RedisString)
rs[:]
end
|
(* Title: ZF/Induct/Comb.thy
Author: Lawrence C Paulson
Copyright 1994 University of Cambridge
*)
section \<open>Combinatory Logic example: the Church-Rosser Theorem\<close>
theory Comb
imports ZF
begin
text \<open>
Curiously, combinators do not include free variables.
Example taken from \<^cite>\<open>camilleri92\<close>.
\<close>
subsection \<open>Definitions\<close>
text \<open>Datatype definition of combinators \<open>S\<close> and \<open>K\<close>.\<close>
consts comb :: i
datatype comb =
K
| S
| app ("p \<in> comb", "q \<in> comb") (infixl \<open>\<bullet>\<close> 90)
text \<open>
Inductive definition of contractions, \<open>\<rightarrow>\<^sup>1\<close> and
(multi-step) reductions, \<open>\<rightarrow>\<close>.
\<close>
consts contract :: i
abbreviation contract_syntax :: "[i,i] \<Rightarrow> o" (infixl \<open>\<rightarrow>\<^sup>1\<close> 50)
where "p \<rightarrow>\<^sup>1 q \<equiv> \<langle>p,q\<rangle> \<in> contract"
abbreviation contract_multi :: "[i,i] \<Rightarrow> o" (infixl \<open>\<rightarrow>\<close> 50)
where "p \<rightarrow> q \<equiv> \<langle>p,q\<rangle> \<in> contract^*"
inductive
domains "contract" \<subseteq> "comb \<times> comb"
intros
K: "\<lbrakk>p \<in> comb; q \<in> comb\<rbrakk> \<Longrightarrow> K\<bullet>p\<bullet>q \<rightarrow>\<^sup>1 p"
S: "\<lbrakk>p \<in> comb; q \<in> comb; r \<in> comb\<rbrakk> \<Longrightarrow> S\<bullet>p\<bullet>q\<bullet>r \<rightarrow>\<^sup>1 (p\<bullet>r)\<bullet>(q\<bullet>r)"
Ap1: "\<lbrakk>p\<rightarrow>\<^sup>1q; r \<in> comb\<rbrakk> \<Longrightarrow> p\<bullet>r \<rightarrow>\<^sup>1 q\<bullet>r"
Ap2: "\<lbrakk>p\<rightarrow>\<^sup>1q; r \<in> comb\<rbrakk> \<Longrightarrow> r\<bullet>p \<rightarrow>\<^sup>1 r\<bullet>q"
type_intros comb.intros
text \<open>
Inductive definition of parallel contractions, \<open>\<Rrightarrow>\<^sup>1\<close> and
(multi-step) parallel reductions, \<open>\<Rrightarrow>\<close>.
\<close>
consts parcontract :: i
abbreviation parcontract_syntax :: "[i,i] \<Rightarrow> o" (infixl \<open>\<Rrightarrow>\<^sup>1\<close> 50)
where "p \<Rrightarrow>\<^sup>1 q \<equiv> \<langle>p,q\<rangle> \<in> parcontract"
abbreviation parcontract_multi :: "[i,i] \<Rightarrow> o" (infixl \<open>\<Rrightarrow>\<close> 50)
where "p \<Rrightarrow> q \<equiv> \<langle>p,q\<rangle> \<in> parcontract^+"
inductive
domains "parcontract" \<subseteq> "comb \<times> comb"
intros
refl: "\<lbrakk>p \<in> comb\<rbrakk> \<Longrightarrow> p \<Rrightarrow>\<^sup>1 p"
K: "\<lbrakk>p \<in> comb; q \<in> comb\<rbrakk> \<Longrightarrow> K\<bullet>p\<bullet>q \<Rrightarrow>\<^sup>1 p"
S: "\<lbrakk>p \<in> comb; q \<in> comb; r \<in> comb\<rbrakk> \<Longrightarrow> S\<bullet>p\<bullet>q\<bullet>r \<Rrightarrow>\<^sup>1 (p\<bullet>r)\<bullet>(q\<bullet>r)"
Ap: "\<lbrakk>p\<Rrightarrow>\<^sup>1q; r\<Rrightarrow>\<^sup>1s\<rbrakk> \<Longrightarrow> p\<bullet>r \<Rrightarrow>\<^sup>1 q\<bullet>s"
type_intros comb.intros
text \<open>
Misc definitions.
\<close>
definition I :: i
where "I \<equiv> S\<bullet>K\<bullet>K"
definition diamond :: "i \<Rightarrow> o"
where "diamond(r) \<equiv>
\<forall>x y. \<langle>x,y\<rangle>\<in>r \<longrightarrow> (\<forall>y'. <x,y'>\<in>r \<longrightarrow> (\<exists>z. \<langle>y,z\<rangle>\<in>r \<and> <y',z> \<in> r))"
subsection \<open>Transitive closure preserves the Church-Rosser property\<close>
lemma diamond_strip_lemmaD [rule_format]:
"\<lbrakk>diamond(r); \<langle>x,y\<rangle>:r^+\<rbrakk> \<Longrightarrow>
\<forall>y'. <x,y'>:r \<longrightarrow> (\<exists>z. <y',z>: r^+ \<and> \<langle>y,z\<rangle>: r)"
unfolding diamond_def
apply (erule trancl_induct)
apply (blast intro: r_into_trancl)
apply clarify
apply (drule spec [THEN mp], assumption)
apply (blast intro: r_into_trancl trans_trancl [THEN transD])
done
lemma diamond_trancl: "diamond(r) \<Longrightarrow> diamond(r^+)"
apply (simp (no_asm_simp) add: diamond_def)
apply (rule impI [THEN allI, THEN allI])
apply (erule trancl_induct)
apply auto
apply (best intro: r_into_trancl trans_trancl [THEN transD]
dest: diamond_strip_lemmaD)+
done
inductive_cases Ap_E [elim!]: "p\<bullet>q \<in> comb"
subsection \<open>Results about Contraction\<close>
text \<open>
For type checking: replaces \<^term>\<open>a \<rightarrow>\<^sup>1 b\<close> by \<open>a, b \<in>
comb\<close>.
\<close>
lemmas contract_combE2 = contract.dom_subset [THEN subsetD, THEN SigmaE2]
and contract_combD1 = contract.dom_subset [THEN subsetD, THEN SigmaD1]
and contract_combD2 = contract.dom_subset [THEN subsetD, THEN SigmaD2]
lemma field_contract_eq: "field(contract) = comb"
by (blast intro: contract.K elim!: contract_combE2)
lemmas reduction_refl =
field_contract_eq [THEN equalityD2, THEN subsetD, THEN rtrancl_refl]
lemmas rtrancl_into_rtrancl2 =
r_into_rtrancl [THEN trans_rtrancl [THEN transD]]
declare reduction_refl [intro!] contract.K [intro!] contract.S [intro!]
lemmas reduction_rls =
contract.K [THEN rtrancl_into_rtrancl2]
contract.S [THEN rtrancl_into_rtrancl2]
contract.Ap1 [THEN rtrancl_into_rtrancl2]
contract.Ap2 [THEN rtrancl_into_rtrancl2]
lemma "p \<in> comb \<Longrightarrow> I\<bullet>p \<rightarrow> p"
\<comment> \<open>Example only: not used\<close>
unfolding I_def by (blast intro: reduction_rls)
lemma comb_I: "I \<in> comb"
unfolding I_def by blast
subsection \<open>Non-contraction results\<close>
text \<open>Derive a case for each combinator constructor.\<close>
inductive_cases K_contractE [elim!]: "K \<rightarrow>\<^sup>1 r"
and S_contractE [elim!]: "S \<rightarrow>\<^sup>1 r"
and Ap_contractE [elim!]: "p\<bullet>q \<rightarrow>\<^sup>1 r"
lemma I_contract_E: "I \<rightarrow>\<^sup>1 r \<Longrightarrow> P"
by (auto simp add: I_def)
lemma K1_contractD: "K\<bullet>p \<rightarrow>\<^sup>1 r \<Longrightarrow> (\<exists>q. r = K\<bullet>q \<and> p \<rightarrow>\<^sup>1 q)"
by auto
lemma Ap_reduce1: "\<lbrakk>p \<rightarrow> q; r \<in> comb\<rbrakk> \<Longrightarrow> p\<bullet>r \<rightarrow> q\<bullet>r"
apply (frule rtrancl_type [THEN subsetD, THEN SigmaD1])
apply (drule field_contract_eq [THEN equalityD1, THEN subsetD])
apply (erule rtrancl_induct)
apply (blast intro: reduction_rls)
apply (erule trans_rtrancl [THEN transD])
apply (blast intro: contract_combD2 reduction_rls)
done
lemma Ap_reduce2: "\<lbrakk>p \<rightarrow> q; r \<in> comb\<rbrakk> \<Longrightarrow> r\<bullet>p \<rightarrow> r\<bullet>q"
apply (frule rtrancl_type [THEN subsetD, THEN SigmaD1])
apply (drule field_contract_eq [THEN equalityD1, THEN subsetD])
apply (erule rtrancl_induct)
apply (blast intro: reduction_rls)
apply (blast intro: trans_rtrancl [THEN transD]
contract_combD2 reduction_rls)
done
text \<open>Counterexample to the diamond property for \<open>\<rightarrow>\<^sup>1\<close>.\<close>
lemma KIII_contract1: "K\<bullet>I\<bullet>(I\<bullet>I) \<rightarrow>\<^sup>1 I"
by (blast intro: comb_I)
lemma KIII_contract2: "K\<bullet>I\<bullet>(I\<bullet>I) \<rightarrow>\<^sup>1 K\<bullet>I\<bullet>((K\<bullet>I)\<bullet>(K\<bullet>I))"
by (unfold I_def) (blast intro: contract.intros)
lemma KIII_contract3: "K\<bullet>I\<bullet>((K\<bullet>I)\<bullet>(K\<bullet>I)) \<rightarrow>\<^sup>1 I"
by (blast intro: comb_I)
lemma not_diamond_contract: "\<not> diamond(contract)"
unfolding diamond_def
apply (blast intro: KIII_contract1 KIII_contract2 KIII_contract3
elim!: I_contract_E)
done
subsection \<open>Results about Parallel Contraction\<close>
text \<open>For type checking: replaces \<open>a \<Rrightarrow>\<^sup>1 b\<close> by \<open>a, b
\<in> comb\<close>\<close>
lemmas parcontract_combE2 = parcontract.dom_subset [THEN subsetD, THEN SigmaE2]
and parcontract_combD1 = parcontract.dom_subset [THEN subsetD, THEN SigmaD1]
and parcontract_combD2 = parcontract.dom_subset [THEN subsetD, THEN SigmaD2]
lemma field_parcontract_eq: "field(parcontract) = comb"
by (blast intro: parcontract.K elim!: parcontract_combE2)
text \<open>Derive a case for each combinator constructor.\<close>
inductive_cases
K_parcontractE [elim!]: "K \<Rrightarrow>\<^sup>1 r"
and S_parcontractE [elim!]: "S \<Rrightarrow>\<^sup>1 r"
and Ap_parcontractE [elim!]: "p\<bullet>q \<Rrightarrow>\<^sup>1 r"
declare parcontract.intros [intro]
subsection \<open>Basic properties of parallel contraction\<close>
lemma K1_parcontractD [dest!]:
"K\<bullet>p \<Rrightarrow>\<^sup>1 r \<Longrightarrow> (\<exists>p'. r = K\<bullet>p' \<and> p \<Rrightarrow>\<^sup>1 p')"
by auto
lemma S1_parcontractD [dest!]:
"S\<bullet>p \<Rrightarrow>\<^sup>1 r \<Longrightarrow> (\<exists>p'. r = S\<bullet>p' \<and> p \<Rrightarrow>\<^sup>1 p')"
by auto
lemma S2_parcontractD [dest!]:
"S\<bullet>p\<bullet>q \<Rrightarrow>\<^sup>1 r \<Longrightarrow> (\<exists>p' q'. r = S\<bullet>p'\<bullet>q' \<and> p \<Rrightarrow>\<^sup>1 p' \<and> q \<Rrightarrow>\<^sup>1 q')"
by auto
lemma diamond_parcontract: "diamond(parcontract)"
\<comment> \<open>Church-Rosser property for parallel contraction\<close>
unfolding diamond_def
apply (rule impI [THEN allI, THEN allI])
apply (erule parcontract.induct)
apply (blast elim!: comb.free_elims intro: parcontract_combD2)+
done
text \<open>
\medskip Equivalence of \<^prop>\<open>p \<rightarrow> q\<close> and \<^prop>\<open>p \<Rrightarrow> q\<close>.
\<close>
lemma contract_imp_parcontract: "p\<rightarrow>\<^sup>1q \<Longrightarrow> p\<Rrightarrow>\<^sup>1q"
by (induct set: contract) auto
lemma reduce_imp_parreduce: "p\<rightarrow>q \<Longrightarrow> p\<Rrightarrow>q"
apply (frule rtrancl_type [THEN subsetD, THEN SigmaD1])
apply (drule field_contract_eq [THEN equalityD1, THEN subsetD])
apply (erule rtrancl_induct)
apply (blast intro: r_into_trancl)
apply (blast intro: contract_imp_parcontract r_into_trancl
trans_trancl [THEN transD])
done
lemma parcontract_imp_reduce: "p\<Rrightarrow>\<^sup>1q \<Longrightarrow> p\<rightarrow>q"
apply (induct set: parcontract)
apply (blast intro: reduction_rls)
apply (blast intro: reduction_rls)
apply (blast intro: reduction_rls)
apply (blast intro: trans_rtrancl [THEN transD]
Ap_reduce1 Ap_reduce2 parcontract_combD1 parcontract_combD2)
done
lemma parreduce_imp_reduce: "p\<Rrightarrow>q \<Longrightarrow> p\<rightarrow>q"
apply (frule trancl_type [THEN subsetD, THEN SigmaD1])
apply (drule field_parcontract_eq [THEN equalityD1, THEN subsetD])
apply (erule trancl_induct, erule parcontract_imp_reduce)
apply (erule trans_rtrancl [THEN transD])
apply (erule parcontract_imp_reduce)
done
lemma parreduce_iff_reduce: "p\<Rrightarrow>q \<longleftrightarrow> p\<rightarrow>q"
by (blast intro: parreduce_imp_reduce reduce_imp_parreduce)
end
|
theory T44
imports Main
begin
lemma "(
(\<forall> x::nat. \<forall> y::nat. meet(x, y) = meet(y, x)) &
(\<forall> x::nat. \<forall> y::nat. join(x, y) = join(y, x)) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(x, meet(y, z)) = meet(meet(x, y), z)) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(x, join(y, z)) = join(join(x, y), z)) &
(\<forall> x::nat. \<forall> y::nat. meet(x, join(x, y)) = x) &
(\<forall> x::nat. \<forall> y::nat. join(x, meet(x, y)) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(x, join(y, z)) = join(mult(x, y), mult(x, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(join(x, y), z) = join(mult(x, z), mult(y, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(x, over(join(mult(x, y), z), y)) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. meet(y, undr(x, join(mult(x, y), z))) = y) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(mult(over(x, y), y), x) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. join(mult(y, undr(y, x)), x) = x) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. over(join(x, y), z) = join(over(x, z), over(y, z))) &
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. undr(meet(x, y), z) = join(undr(x, z), undr(y, z))) &
(\<forall> x::nat. \<forall> y::nat. invo(join(x, y)) = meet(invo(x), invo(y))) &
(\<forall> x::nat. \<forall> y::nat. invo(meet(x, y)) = join(invo(x), invo(y))) &
(\<forall> x::nat. invo(invo(x)) = x)
) \<longrightarrow>
(\<forall> x::nat. \<forall> y::nat. \<forall> z::nat. mult(meet(x, y), z) = meet(mult(x, z), mult(y, z)))
"
nitpick[card nat=4,timeout=86400]
oops
end |
[STATEMENT]
lemma scaleR_vector_matrix_assoc:
fixes k :: real and x :: "real^'n" and A :: "real^'m^'n"
shows "(k *\<^sub>R x) v* A = k *\<^sub>R (x v* A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. k *\<^sub>R x v* A = k *\<^sub>R (x v* A)
[PROOF STEP]
by (metis matrix_vector_mult_scaleR transpose_matrix_vector) |
[STATEMENT]
lemma compose_Bij: "\<lbrakk>x \<in> Bij S; y \<in> Bij S\<rbrakk> \<Longrightarrow> compose S x y \<in> Bij S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>x \<in> Bij S; y \<in> Bij S\<rbrakk> \<Longrightarrow> compose S x y \<in> Bij S
[PROOF STEP]
by (auto simp add: Bij_def bij_betw_compose) |
[STATEMENT]
lemma vrange_vsubset_vtimes:
assumes "vpairs r \<subseteq>\<^sub>\<circ> x \<times>\<^sub>\<circ> y"
shows "\<R>\<^sub>\<circ> r \<subseteq>\<^sub>\<circ> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<R>\<^sub>\<circ> r \<subseteq>\<^sub>\<circ> y
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
vpairs r \<subseteq>\<^sub>\<circ> x \<times>\<^sub>\<circ> y
goal (1 subgoal):
1. \<R>\<^sub>\<circ> r \<subseteq>\<^sub>\<circ> y
[PROOF STEP]
by auto |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.