text
stringlengths 0
3.34M
|
---|
lemma example2 (x y : mynat) (h : y = x + 7) : 2 * y = 2 * (x + 7) :=
begin
rw ← h,
refl,
end |
[GOAL]
⊢ DecidableRel fun x x_1 => x < x_1
[PROOFSTEP]
simp only [LT']
[GOAL]
⊢ DecidableRel fun s₁ s₂ => ltb (iter s₁) (iter s₂) = true
[PROOFSTEP]
infer_instance
-- short-circuit type class inference
[GOAL]
c : Char
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ ltb { s := { data := c :: cs₁ }, i := i₁ + c } { s := { data := c :: cs₂ }, i := i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ } { s := { data := cs₂ }, i := i₂ }
[PROOFSTEP]
apply
ltb.inductionOn ⟨⟨cs₁⟩, i₁⟩ ⟨⟨cs₂⟩, i₂⟩ (motive := fun ⟨⟨cs₁⟩, i₁⟩ ⟨⟨cs₂⟩, i₂⟩ ↦
ltb ⟨⟨c :: cs₁⟩, i₁ + c⟩ ⟨⟨c :: cs₂⟩, i₂ + c⟩ = ltb ⟨⟨cs₁⟩, i₁⟩ ⟨⟨cs₂⟩, i₂⟩)
[GOAL]
case ind
c : Char
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ ∀ (s₁ s₂ : String) (i₁ i₂ : Pos),
Iterator.hasNext { s := s₂, i := i₂ } = true →
Iterator.hasNext { s := s₁, i := i₁ } = true →
get s₁ i₁ = get s₂ i₂ →
(match Iterator.next { s := s₁, i := i₁ } with
| { s := { data := cs₁ }, i := i₁ } =>
match Iterator.next { s := s₂, i := i₂ } with
| { s := { data := cs₂ }, i := i₂ } =>
ltb { s := { data := c :: cs₁ }, i := i₁ + c } { s := { data := c :: cs₂ }, i := i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ } { s := { data := cs₂ }, i := i₂ }) →
match { s := s₁, i := i₁ } with
| { s := { data := cs₁ }, i := i₁ } =>
match { s := s₂, i := i₂ } with
| { s := { data := cs₂ }, i := i₂ } =>
ltb { s := { data := c :: cs₁ }, i := i₁ + c } { s := { data := c :: cs₂ }, i := i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ } { s := { data := cs₂ }, i := i₂ }
[PROOFSTEP]
simp
[GOAL]
case eq
c : Char
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ ∀ (s₁ s₂ : String) (i₁ i₂ : Pos),
Iterator.hasNext { s := s₂, i := i₂ } = true →
Iterator.hasNext { s := s₁, i := i₁ } = true →
¬get s₁ i₁ = get s₂ i₂ →
match { s := s₁, i := i₁ } with
| { s := { data := cs₁ }, i := i₁ } =>
match { s := s₂, i := i₂ } with
| { s := { data := cs₂ }, i := i₂ } =>
ltb { s := { data := c :: cs₁ }, i := i₁ + c } { s := { data := c :: cs₂ }, i := i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ } { s := { data := cs₂ }, i := i₂ }
[PROOFSTEP]
simp
[GOAL]
case base₁
c : Char
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ ∀ (s₁ s₂ : String) (i₁ i₂ : Pos),
Iterator.hasNext { s := s₂, i := i₂ } = true →
¬Iterator.hasNext { s := s₁, i := i₁ } = true →
match { s := s₁, i := i₁ } with
| { s := { data := cs₁ }, i := i₁ } =>
match { s := s₂, i := i₂ } with
| { s := { data := cs₂ }, i := i₂ } =>
ltb { s := { data := c :: cs₁ }, i := i₁ + c } { s := { data := c :: cs₂ }, i := i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ } { s := { data := cs₂ }, i := i₂ }
[PROOFSTEP]
simp
[GOAL]
case base₂
c : Char
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ ∀ (s₁ s₂ : String) (i₁ i₂ : Pos),
¬Iterator.hasNext { s := s₂, i := i₂ } = true →
match { s := s₁, i := i₁ } with
| { s := { data := cs₁ }, i := i₁ } =>
match { s := s₂, i := i₂ } with
| { s := { data := cs₂ }, i := i₂ } =>
ltb { s := { data := c :: cs₁ }, i := i₁ + c } { s := { data := c :: cs₂ }, i := i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ } { s := { data := cs₂ }, i := i₂ }
[PROOFSTEP]
simp
[GOAL]
case ind
c : Char
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ ∀ (s₁ s₂ : String) (i₁ i₂ : Pos),
Iterator.hasNext { s := s₂, i := i₂ } = true →
Iterator.hasNext { s := s₁, i := i₁ } = true →
get s₁ i₁ = get s₂ i₂ →
ltb
{ s := { data := c :: (Iterator.next { s := s₁, i := i₁ }).1.data },
i := (Iterator.next { s := s₁, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := s₂, i := i₂ }).1.data },
i := (Iterator.next { s := s₂, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := s₁, i := i₁ }).1.data },
i := (Iterator.next { s := s₁, i := i₁ }).i }
{ s := { data := (Iterator.next { s := s₂, i := i₂ }).1.data },
i := (Iterator.next { s := s₂, i := i₂ }).i } →
ltb { s := { data := c :: s₁.data }, i := i₁ + c } { s := { data := c :: s₂.data }, i := i₂ + c } =
ltb { s := { data := s₁.data }, i := i₁ } { s := { data := s₂.data }, i := i₂ }
[PROOFSTEP]
intro ⟨cs₁⟩ ⟨cs₂⟩ i₁ i₂
[GOAL]
case eq
c : Char
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ ∀ (s₁ s₂ : String) (i₁ i₂ : Pos),
Iterator.hasNext { s := s₂, i := i₂ } = true →
Iterator.hasNext { s := s₁, i := i₁ } = true →
¬get s₁ i₁ = get s₂ i₂ →
ltb { s := { data := c :: s₁.data }, i := i₁ + c } { s := { data := c :: s₂.data }, i := i₂ + c } =
ltb { s := { data := s₁.data }, i := i₁ } { s := { data := s₂.data }, i := i₂ }
[PROOFSTEP]
intro ⟨cs₁⟩ ⟨cs₂⟩ i₁ i₂
[GOAL]
case base₁
c : Char
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ ∀ (s₁ s₂ : String) (i₁ i₂ : Pos),
Iterator.hasNext { s := s₂, i := i₂ } = true →
Iterator.hasNext { s := s₁, i := i₁ } = false →
ltb { s := { data := c :: s₁.data }, i := i₁ + c } { s := { data := c :: s₂.data }, i := i₂ + c } =
ltb { s := { data := s₁.data }, i := i₁ } { s := { data := s₂.data }, i := i₂ }
[PROOFSTEP]
intro ⟨cs₁⟩ ⟨cs₂⟩ i₁ i₂
[GOAL]
case base₂
c : Char
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ ∀ (s₁ s₂ : String) (i₁ i₂ : Pos),
Iterator.hasNext { s := s₂, i := i₂ } = false →
ltb { s := { data := c :: s₁.data }, i := i₁ + c } { s := { data := c :: s₂.data }, i := i₂ + c } =
ltb { s := { data := s₁.data }, i := i₁ } { s := { data := s₂.data }, i := i₂ }
[PROOFSTEP]
intro ⟨cs₁⟩ ⟨cs₂⟩ i₁ i₂
[GOAL]
case ind
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true →
Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true →
get { data := cs₁ } i₁ = get { data := cs₂ } i₂ →
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i } →
ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
intros
[GOAL]
case eq
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true →
Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true →
¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂ →
ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
intros
[GOAL]
case base₁
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true →
Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false →
ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
intros
[GOAL]
case base₂
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
⊢ Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false →
ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
intros
[GOAL]
case ind
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
⊢ ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
conv => lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c }
[PROOFSTEP]
rw [ltb]
[GOAL]
case eq
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
⊢ ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
conv => lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c }
[PROOFSTEP]
rw [ltb]
[GOAL]
case base₁
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝¹ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false
⊢ ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
conv => lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝¹ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝¹ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝¹ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝¹ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c }
[PROOFSTEP]
rw [ltb]
[GOAL]
case base₂
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false
⊢ ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
conv => lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
lhs
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false
| ltb { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c }
{ s := { data := c :: { data := cs₂ }.data }, i := i₂ + c }
[PROOFSTEP]
rw [ltb]
[GOAL]
case ind
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
⊢ (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
conv => rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
| ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rw [ltb]
[GOAL]
case eq
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
⊢ (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
conv => rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
| ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rw [ltb]
[GOAL]
case base₁
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝¹ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false
⊢ (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
conv => rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝¹ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝¹ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝¹ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝¹ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false
| ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rw [ltb]
[GOAL]
case base₂
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false
⊢ (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
conv => rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs; rw [ltb]
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false
| (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rhs
[GOAL]
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false
| ltb { s := { data := { data := cs₁ }.data }, i := i₁ } { s := { data := { data := cs₂ }.data }, i := i₂ }
[PROOFSTEP]
rw [ltb]
[GOAL]
case ind
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
⊢ (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
if Iterator.hasNext { s := { data := { data := cs₂ }.data }, i := i₂ } = true then
if Iterator.hasNext { s := { data := { data := cs₁ }.data }, i := i₁ } = true then
if
Iterator.curr { s := { data := { data := cs₁ }.data }, i := i₁ } =
Iterator.curr { s := { data := { data := cs₂ }.data }, i := i₂ } then
ltb (Iterator.next { s := { data := { data := cs₁ }.data }, i := i₁ })
(Iterator.next { s := { data := { data := cs₂ }.data }, i := i₂ })
else
decide
(Iterator.curr { s := { data := { data := cs₁ }.data }, i := i₁ } <
Iterator.curr { s := { data := { data := cs₂ }.data }, i := i₂ })
else true
else false
[PROOFSTEP]
simp [Iterator.hasNext_cons_addChar, *]
[GOAL]
case eq
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
⊢ (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
if Iterator.hasNext { s := { data := { data := cs₂ }.data }, i := i₂ } = true then
if Iterator.hasNext { s := { data := { data := cs₁ }.data }, i := i₁ } = true then
if
Iterator.curr { s := { data := { data := cs₁ }.data }, i := i₁ } =
Iterator.curr { s := { data := { data := cs₂ }.data }, i := i₂ } then
ltb (Iterator.next { s := { data := { data := cs₁ }.data }, i := i₁ })
(Iterator.next { s := { data := { data := cs₂ }.data }, i := i₂ })
else
decide
(Iterator.curr { s := { data := { data := cs₁ }.data }, i := i₁ } <
Iterator.curr { s := { data := { data := cs₂ }.data }, i := i₂ })
else true
else false
[PROOFSTEP]
simp [Iterator.hasNext_cons_addChar, *]
[GOAL]
case base₁
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝¹ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = false
⊢ (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
if Iterator.hasNext { s := { data := { data := cs₂ }.data }, i := i₂ } = true then
if Iterator.hasNext { s := { data := { data := cs₁ }.data }, i := i₁ } = true then
if
Iterator.curr { s := { data := { data := cs₁ }.data }, i := i₁ } =
Iterator.curr { s := { data := { data := cs₂ }.data }, i := i₂ } then
ltb (Iterator.next { s := { data := { data := cs₁ }.data }, i := i₁ })
(Iterator.next { s := { data := { data := cs₂ }.data }, i := i₂ })
else
decide
(Iterator.curr { s := { data := { data := cs₁ }.data }, i := i₁ } <
Iterator.curr { s := { data := { data := cs₂ }.data }, i := i₂ })
else true
else false
[PROOFSTEP]
simp [Iterator.hasNext_cons_addChar, *]
[GOAL]
case base₂
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = false
⊢ (if Iterator.hasNext { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } = true then
if Iterator.hasNext { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } = true then
if
Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } =
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c })
(Iterator.next { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: { data := cs₁ }.data }, i := i₁ + c } <
Iterator.curr { s := { data := c :: { data := cs₂ }.data }, i := i₂ + c })
else true
else false) =
if Iterator.hasNext { s := { data := { data := cs₂ }.data }, i := i₂ } = true then
if Iterator.hasNext { s := { data := { data := cs₁ }.data }, i := i₁ } = true then
if
Iterator.curr { s := { data := { data := cs₁ }.data }, i := i₁ } =
Iterator.curr { s := { data := { data := cs₂ }.data }, i := i₂ } then
ltb (Iterator.next { s := { data := { data := cs₁ }.data }, i := i₁ })
(Iterator.next { s := { data := { data := cs₂ }.data }, i := i₂ })
else
decide
(Iterator.curr { s := { data := { data := cs₁ }.data }, i := i₁ } <
Iterator.curr { s := { data := { data := cs₂ }.data }, i := i₂ })
else true
else false
[PROOFSTEP]
simp [Iterator.hasNext_cons_addChar, *]
[GOAL]
case ind
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝³ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝² : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝¹ : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
a✝ :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
⊢ (if
Iterator.curr { s := { data := c :: cs₁ }, i := i₁ + c } =
Iterator.curr { s := { data := c :: cs₂ }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: cs₁ }, i := i₁ + c })
(Iterator.next { s := { data := c :: cs₂ }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: cs₁ }, i := i₁ + c } <
Iterator.curr { s := { data := c :: cs₂ }, i := i₂ + c })) =
if Iterator.curr { s := { data := cs₁ }, i := i₁ } = Iterator.curr { s := { data := cs₂ }, i := i₂ } then
ltb (Iterator.next { s := { data := cs₁ }, i := i₁ }) (Iterator.next { s := { data := cs₂ }, i := i₂ })
else decide (Iterator.curr { s := { data := cs₁ }, i := i₁ } < Iterator.curr { s := { data := cs₂ }, i := i₂ })
[PROOFSTEP]
rename_i h₂ h₁ heq ih
[GOAL]
case ind
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
h₂ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
h₁ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
heq : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
ih :
ltb
{ s := { data := c :: (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i + c }
{ s := { data := c :: (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i + c } =
ltb
{ s := { data := (Iterator.next { s := { data := cs₁ }, i := i₁ }).1.data },
i := (Iterator.next { s := { data := cs₁ }, i := i₁ }).i }
{ s := { data := (Iterator.next { s := { data := cs₂ }, i := i₂ }).1.data },
i := (Iterator.next { s := { data := cs₂ }, i := i₂ }).i }
⊢ (if
Iterator.curr { s := { data := c :: cs₁ }, i := i₁ + c } =
Iterator.curr { s := { data := c :: cs₂ }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: cs₁ }, i := i₁ + c })
(Iterator.next { s := { data := c :: cs₂ }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: cs₁ }, i := i₁ + c } <
Iterator.curr { s := { data := c :: cs₂ }, i := i₂ + c })) =
if Iterator.curr { s := { data := cs₁ }, i := i₁ } = Iterator.curr { s := { data := cs₂ }, i := i₂ } then
ltb (Iterator.next { s := { data := cs₁ }, i := i₁ }) (Iterator.next { s := { data := cs₂ }, i := i₂ })
else decide (Iterator.curr { s := { data := cs₁ }, i := i₁ } < Iterator.curr { s := { data := cs₂ }, i := i₂ })
[PROOFSTEP]
simp [Iterator.curr, get_cons_addChar, Iterator.next, next, *] at *
[GOAL]
case ind
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
h₂ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
h₁ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
heq : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
ih :
ltb { s := { data := c :: cs₁ }, i := i₁ + get { data := cs₂ } i₂ + c }
{ s := { data := c :: cs₂ }, i := i₂ + get { data := cs₂ } i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ + get { data := cs₂ } i₂ }
{ s := { data := cs₂ }, i := i₂ + get { data := cs₂ } i₂ }
⊢ ltb { s := { data := c :: cs₁ }, i := i₁ + c + get { data := cs₂ } i₂ }
{ s := { data := c :: cs₂ }, i := i₂ + c + get { data := cs₂ } i₂ } =
ltb { s := { data := cs₁ }, i := i₁ + get { data := cs₂ } i₂ }
{ s := { data := cs₂ }, i := i₂ + get { data := cs₂ } i₂ }
[PROOFSTEP]
repeat rw [Pos.addChar_right_comm _ c]
[GOAL]
case ind
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
h₂ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
h₁ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
heq : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
ih :
ltb { s := { data := c :: cs₁ }, i := i₁ + get { data := cs₂ } i₂ + c }
{ s := { data := c :: cs₂ }, i := i₂ + get { data := cs₂ } i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ + get { data := cs₂ } i₂ }
{ s := { data := cs₂ }, i := i₂ + get { data := cs₂ } i₂ }
⊢ ltb { s := { data := c :: cs₁ }, i := i₁ + c + get { data := cs₂ } i₂ }
{ s := { data := c :: cs₂ }, i := i₂ + c + get { data := cs₂ } i₂ } =
ltb { s := { data := cs₁ }, i := i₁ + get { data := cs₂ } i₂ }
{ s := { data := cs₂ }, i := i₂ + get { data := cs₂ } i₂ }
[PROOFSTEP]
rw [Pos.addChar_right_comm _ c]
[GOAL]
case ind
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
h₂ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
h₁ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
heq : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
ih :
ltb { s := { data := c :: cs₁ }, i := i₁ + get { data := cs₂ } i₂ + c }
{ s := { data := c :: cs₂ }, i := i₂ + get { data := cs₂ } i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ + get { data := cs₂ } i₂ }
{ s := { data := cs₂ }, i := i₂ + get { data := cs₂ } i₂ }
⊢ ltb { s := { data := c :: cs₁ }, i := i₁ + get { data := cs₂ } i₂ + c }
{ s := { data := c :: cs₂ }, i := i₂ + c + get { data := cs₂ } i₂ } =
ltb { s := { data := cs₁ }, i := i₁ + get { data := cs₂ } i₂ }
{ s := { data := cs₂ }, i := i₂ + get { data := cs₂ } i₂ }
[PROOFSTEP]
rw [Pos.addChar_right_comm _ c]
[GOAL]
case ind
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
h₂ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
h₁ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
heq : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
ih :
ltb { s := { data := c :: cs₁ }, i := i₁ + get { data := cs₂ } i₂ + c }
{ s := { data := c :: cs₂ }, i := i₂ + get { data := cs₂ } i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ + get { data := cs₂ } i₂ }
{ s := { data := cs₂ }, i := i₂ + get { data := cs₂ } i₂ }
⊢ ltb { s := { data := c :: cs₁ }, i := i₁ + get { data := cs₂ } i₂ + c }
{ s := { data := c :: cs₂ }, i := i₂ + get { data := cs₂ } i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ + get { data := cs₂ } i₂ }
{ s := { data := cs₂ }, i := i₂ + get { data := cs₂ } i₂ }
[PROOFSTEP]
rw [Pos.addChar_right_comm _ c]
[GOAL]
case ind
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
h₂ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
h₁ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
heq : get { data := cs₁ } i₁ = get { data := cs₂ } i₂
ih :
ltb { s := { data := c :: cs₁ }, i := i₁ + get { data := cs₂ } i₂ + c }
{ s := { data := c :: cs₂ }, i := i₂ + get { data := cs₂ } i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ + get { data := cs₂ } i₂ }
{ s := { data := cs₂ }, i := i₂ + get { data := cs₂ } i₂ }
⊢ ltb { s := { data := c :: cs₁ }, i := i₁ + get { data := cs₂ } i₂ + c }
{ s := { data := c :: cs₂ }, i := i₂ + get { data := cs₂ } i₂ + c } =
ltb { s := { data := cs₁ }, i := i₁ + get { data := cs₂ } i₂ }
{ s := { data := cs₂ }, i := i₂ + get { data := cs₂ } i₂ }
[PROOFSTEP]
exact ih
[GOAL]
case eq
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
a✝² : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
a✝¹ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
a✝ : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
⊢ (if
Iterator.curr { s := { data := c :: cs₁ }, i := i₁ + c } =
Iterator.curr { s := { data := c :: cs₂ }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: cs₁ }, i := i₁ + c })
(Iterator.next { s := { data := c :: cs₂ }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: cs₁ }, i := i₁ + c } <
Iterator.curr { s := { data := c :: cs₂ }, i := i₂ + c })) =
if Iterator.curr { s := { data := cs₁ }, i := i₁ } = Iterator.curr { s := { data := cs₂ }, i := i₂ } then
ltb (Iterator.next { s := { data := cs₁ }, i := i₁ }) (Iterator.next { s := { data := cs₂ }, i := i₂ })
else decide (Iterator.curr { s := { data := cs₁ }, i := i₁ } < Iterator.curr { s := { data := cs₂ }, i := i₂ })
[PROOFSTEP]
rename_i h₂ h₁ hne
[GOAL]
case eq
c : Char
cs₁✝ cs₂✝ : List Char
i₁✝ i₂✝ : Pos
cs₁ cs₂ : List Char
i₁ i₂ : Pos
h₂ : Iterator.hasNext { s := { data := cs₂ }, i := i₂ } = true
h₁ : Iterator.hasNext { s := { data := cs₁ }, i := i₁ } = true
hne : ¬get { data := cs₁ } i₁ = get { data := cs₂ } i₂
⊢ (if
Iterator.curr { s := { data := c :: cs₁ }, i := i₁ + c } =
Iterator.curr { s := { data := c :: cs₂ }, i := i₂ + c } then
ltb (Iterator.next { s := { data := c :: cs₁ }, i := i₁ + c })
(Iterator.next { s := { data := c :: cs₂ }, i := i₂ + c })
else
decide
(Iterator.curr { s := { data := c :: cs₁ }, i := i₁ + c } <
Iterator.curr { s := { data := c :: cs₂ }, i := i₂ + c })) =
if Iterator.curr { s := { data := cs₁ }, i := i₁ } = Iterator.curr { s := { data := cs₂ }, i := i₂ } then
ltb (Iterator.next { s := { data := cs₁ }, i := i₁ }) (Iterator.next { s := { data := cs₂ }, i := i₂ })
else decide (Iterator.curr { s := { data := cs₁ }, i := i₁ } < Iterator.curr { s := { data := cs₂ }, i := i₂ })
[PROOFSTEP]
simp [Iterator.curr, get_cons_addChar, *]
[GOAL]
s₁ s₂ : List Char
⊢ ltb { s := { data := s₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ s₁ < s₂
[PROOFSTEP]
induction s₁ generalizing s₂
[GOAL]
case nil
s₂ : List Char
⊢ ltb { s := { data := [] }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ [] < s₂
[PROOFSTEP]
cases s₂
[GOAL]
case cons
head✝ : Char
tail✝ : List Char
tail_ih✝ :
∀ (s₂ : List Char), ltb { s := { data := tail✝ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ tail✝ < s₂
s₂ : List Char
⊢ ltb { s := { data := head✝ :: tail✝ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ head✝ :: tail✝ < s₂
[PROOFSTEP]
cases s₂
[GOAL]
case nil.nil
⊢ ltb { s := { data := [] }, i := 0 } { s := { data := [] }, i := 0 } = true ↔ [] < []
[PROOFSTEP]
simp
[GOAL]
case nil.cons
head✝ : Char
tail✝ : List Char
⊢ ltb { s := { data := [] }, i := 0 } { s := { data := head✝ :: tail✝ }, i := 0 } = true ↔ [] < head✝ :: tail✝
[PROOFSTEP]
rename_i c₂ cs₂
[GOAL]
case nil.cons
c₂ : Char
cs₂ : List Char
⊢ ltb { s := { data := [] }, i := 0 } { s := { data := c₂ :: cs₂ }, i := 0 } = true ↔ [] < c₂ :: cs₂
[PROOFSTEP]
apply iff_of_true
[GOAL]
case nil.cons.ha
c₂ : Char
cs₂ : List Char
⊢ ltb { s := { data := [] }, i := 0 } { s := { data := c₂ :: cs₂ }, i := 0 } = true
[PROOFSTEP]
rw [ltb]
[GOAL]
case nil.cons.ha
c₂ : Char
cs₂ : List Char
⊢ (if Iterator.hasNext { s := { data := c₂ :: cs₂ }, i := 0 } = true then
if Iterator.hasNext { s := { data := [] }, i := 0 } = true then
if Iterator.curr { s := { data := [] }, i := 0 } = Iterator.curr { s := { data := c₂ :: cs₂ }, i := 0 } then
ltb (Iterator.next { s := { data := [] }, i := 0 }) (Iterator.next { s := { data := c₂ :: cs₂ }, i := 0 })
else
decide (Iterator.curr { s := { data := [] }, i := 0 } < Iterator.curr { s := { data := c₂ :: cs₂ }, i := 0 })
else true
else false) =
true
[PROOFSTEP]
simp
[GOAL]
case nil.cons.ha
c₂ : Char
cs₂ : List Char
⊢ Iterator.hasNext { s := { data := c₂ :: cs₂ }, i := 0 } = false → False
[PROOFSTEP]
apply ne_false_of_eq_true
[GOAL]
case nil.cons.ha.a
c₂ : Char
cs₂ : List Char
⊢ Iterator.hasNext { s := { data := c₂ :: cs₂ }, i := 0 } = true
[PROOFSTEP]
apply decide_eq_true
[GOAL]
case nil.cons.ha.a.a
c₂ : Char
cs₂ : List Char
⊢ 0.byteIdx < (endPos { data := c₂ :: cs₂ }).byteIdx
[PROOFSTEP]
simp [endPos, utf8ByteSize, utf8ByteSize.go, csize_pos]
[GOAL]
case nil.cons.hb
c₂ : Char
cs₂ : List Char
⊢ [] < c₂ :: cs₂
[PROOFSTEP]
apply List.nil_lt_cons
[GOAL]
case cons.nil
head✝ : Char
tail✝ : List Char
tail_ih✝ :
∀ (s₂ : List Char), ltb { s := { data := tail✝ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ tail✝ < s₂
⊢ ltb { s := { data := head✝ :: tail✝ }, i := 0 } { s := { data := [] }, i := 0 } = true ↔ head✝ :: tail✝ < []
[PROOFSTEP]
rename_i c₁ cs₁ ih
[GOAL]
case cons.nil
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
⊢ ltb { s := { data := c₁ :: cs₁ }, i := 0 } { s := { data := [] }, i := 0 } = true ↔ c₁ :: cs₁ < []
[PROOFSTEP]
apply iff_of_false
[GOAL]
case cons.nil.ha
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
⊢ ¬ltb { s := { data := c₁ :: cs₁ }, i := 0 } { s := { data := [] }, i := 0 } = true
[PROOFSTEP]
rw [ltb]
[GOAL]
case cons.nil.ha
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
⊢ ¬(if Iterator.hasNext { s := { data := [] }, i := 0 } = true then
if Iterator.hasNext { s := { data := c₁ :: cs₁ }, i := 0 } = true then
if Iterator.curr { s := { data := c₁ :: cs₁ }, i := 0 } = Iterator.curr { s := { data := [] }, i := 0 } then
ltb (Iterator.next { s := { data := c₁ :: cs₁ }, i := 0 }) (Iterator.next { s := { data := [] }, i := 0 })
else
decide
(Iterator.curr { s := { data := c₁ :: cs₁ }, i := 0 } < Iterator.curr { s := { data := [] }, i := 0 })
else true
else false) =
true
[PROOFSTEP]
simp
[GOAL]
case cons.nil.hb
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
⊢ ¬c₁ :: cs₁ < []
[PROOFSTEP]
apply not_lt_of_lt
[GOAL]
case cons.nil.hb.a
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
⊢ [] < c₁ :: cs₁
[PROOFSTEP]
apply List.nil_lt_cons
[GOAL]
case cons.cons
head✝¹ : Char
tail✝¹ : List Char
tail_ih✝ :
∀ (s₂ : List Char), ltb { s := { data := tail✝¹ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ tail✝¹ < s₂
head✝ : Char
tail✝ : List Char
⊢ ltb { s := { data := head✝¹ :: tail✝¹ }, i := 0 } { s := { data := head✝ :: tail✝ }, i := 0 } = true ↔
head✝¹ :: tail✝¹ < head✝ :: tail✝
[PROOFSTEP]
rename_i c₁ cs₁ ih c₂ cs₂
[GOAL]
case cons.cons
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
c₂ : Char
cs₂ : List Char
⊢ ltb { s := { data := c₁ :: cs₁ }, i := 0 } { s := { data := c₂ :: cs₂ }, i := 0 } = true ↔ c₁ :: cs₁ < c₂ :: cs₂
[PROOFSTEP]
rw [ltb]
[GOAL]
case cons.cons
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
c₂ : Char
cs₂ : List Char
⊢ (if Iterator.hasNext { s := { data := c₂ :: cs₂ }, i := 0 } = true then
if Iterator.hasNext { s := { data := c₁ :: cs₁ }, i := 0 } = true then
if
Iterator.curr { s := { data := c₁ :: cs₁ }, i := 0 } =
Iterator.curr { s := { data := c₂ :: cs₂ }, i := 0 } then
ltb (Iterator.next { s := { data := c₁ :: cs₁ }, i := 0 })
(Iterator.next { s := { data := c₂ :: cs₂ }, i := 0 })
else
decide
(Iterator.curr { s := { data := c₁ :: cs₁ }, i := 0 } <
Iterator.curr { s := { data := c₂ :: cs₂ }, i := 0 })
else true
else false) =
true ↔
c₁ :: cs₁ < c₂ :: cs₂
[PROOFSTEP]
simp [Iterator.hasNext, endPos, utf8ByteSize, utf8ByteSize.go, csize_pos, Iterator.curr, get, utf8GetAux, Iterator.next,
next]
[GOAL]
case cons.cons
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
c₂ : Char
cs₂ : List Char
⊢ (if c₁ = c₂ then ltb { s := { data := c₁ :: cs₁ }, i := 0 + c₁ } { s := { data := c₂ :: cs₂ }, i := 0 + c₂ } = true
else c₁ < c₂) ↔
c₁ :: cs₁ < c₂ :: cs₂
[PROOFSTEP]
split_ifs with h
[GOAL]
case pos
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
c₂ : Char
cs₂ : List Char
h : c₁ = c₂
⊢ ltb { s := { data := c₁ :: cs₁ }, i := 0 + c₁ } { s := { data := c₂ :: cs₂ }, i := 0 + c₂ } = true ↔
c₁ :: cs₁ < c₂ :: cs₂
[PROOFSTEP]
subst c₂
[GOAL]
case pos
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
cs₂ : List Char
⊢ ltb { s := { data := c₁ :: cs₁ }, i := 0 + c₁ } { s := { data := c₁ :: cs₂ }, i := 0 + c₁ } = true ↔
c₁ :: cs₁ < c₁ :: cs₂
[PROOFSTEP]
suffices ltb ⟨⟨c₁ :: cs₁⟩, ⟨csize c₁⟩⟩ ⟨⟨c₁ :: cs₂⟩, ⟨csize c₁⟩⟩ = ltb ⟨⟨cs₁⟩, 0⟩ ⟨⟨cs₂⟩, 0⟩ by
rw [Pos.zero_addChar_eq, this]; exact (ih cs₂).trans List.Lex.cons_iff.symm
[GOAL]
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
cs₂ : List Char
this :
ltb { s := { data := c₁ :: cs₁ }, i := { byteIdx := csize c₁ } }
{ s := { data := c₁ :: cs₂ }, i := { byteIdx := csize c₁ } } =
ltb { s := { data := cs₁ }, i := 0 } { s := { data := cs₂ }, i := 0 }
⊢ ltb { s := { data := c₁ :: cs₁ }, i := 0 + c₁ } { s := { data := c₁ :: cs₂ }, i := 0 + c₁ } = true ↔
c₁ :: cs₁ < c₁ :: cs₂
[PROOFSTEP]
rw [Pos.zero_addChar_eq, this]
[GOAL]
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
cs₂ : List Char
this :
ltb { s := { data := c₁ :: cs₁ }, i := { byteIdx := csize c₁ } }
{ s := { data := c₁ :: cs₂ }, i := { byteIdx := csize c₁ } } =
ltb { s := { data := cs₁ }, i := 0 } { s := { data := cs₂ }, i := 0 }
⊢ ltb { s := { data := cs₁ }, i := 0 } { s := { data := cs₂ }, i := 0 } = true ↔ c₁ :: cs₁ < c₁ :: cs₂
[PROOFSTEP]
exact (ih cs₂).trans List.Lex.cons_iff.symm
[GOAL]
case pos
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
cs₂ : List Char
⊢ ltb { s := { data := c₁ :: cs₁ }, i := { byteIdx := csize c₁ } }
{ s := { data := c₁ :: cs₂ }, i := { byteIdx := csize c₁ } } =
ltb { s := { data := cs₁ }, i := 0 } { s := { data := cs₂ }, i := 0 }
[PROOFSTEP]
rw [← Pos.zero_addChar_eq]
[GOAL]
case pos
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
cs₂ : List Char
⊢ ltb { s := { data := c₁ :: cs₁ }, i := 0 + c₁ } { s := { data := c₁ :: cs₂ }, i := 0 + c₁ } =
ltb { s := { data := cs₁ }, i := 0 } { s := { data := cs₂ }, i := 0 }
[PROOFSTEP]
apply ltb_cons_addChar
[GOAL]
case neg
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
c₂ : Char
cs₂ : List Char
h : ¬c₁ = c₂
⊢ c₁ < c₂ ↔ c₁ :: cs₁ < c₂ :: cs₂
[PROOFSTEP]
refine ⟨List.Lex.rel, fun e ↦ ?_⟩
[GOAL]
case neg
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
c₂ : Char
cs₂ : List Char
h : ¬c₁ = c₂
e : c₁ :: cs₁ < c₂ :: cs₂
⊢ c₁ < c₂
[PROOFSTEP]
cases e
[GOAL]
case neg.cons
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
cs₂ : List Char
h : ¬c₁ = c₁
h✝ : List.Lex (fun x x_1 => x < x_1) cs₁ cs₂
⊢ c₁ < c₁
[PROOFSTEP]
rename_i h'
[GOAL]
case neg.rel
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
c₂ : Char
cs₂ : List Char
h : ¬c₁ = c₂
h✝ : c₁ < c₂
⊢ c₁ < c₂
[PROOFSTEP]
rename_i h'
[GOAL]
case neg.cons
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
cs₂ : List Char
h : ¬c₁ = c₁
h' : List.Lex (fun x x_1 => x < x_1) cs₁ cs₂
⊢ c₁ < c₁
[PROOFSTEP]
contradiction
[GOAL]
case neg.rel
c₁ : Char
cs₁ : List Char
ih : ∀ (s₂ : List Char), ltb { s := { data := cs₁ }, i := 0 } { s := { data := s₂ }, i := 0 } = true ↔ cs₁ < s₂
c₂ : Char
cs₂ : List Char
h : ¬c₁ = c₂
h' : c₁ < c₂
⊢ c₁ < c₂
[PROOFSTEP]
assumption
[GOAL]
⊢ DecidableRel fun x x_1 => x ≤ x_1
[PROOFSTEP]
simp only [LE]
[GOAL]
⊢ DecidableRel fun s₁ s₂ => ¬s₂ < s₁
[PROOFSTEP]
infer_instance
-- short-circuit type class inference
[GOAL]
s : List Char
h : { data := s } ≠ ""
⊢ toList { data := s } = head { data := s } :: toList (drop { data := s } 1)
[PROOFSTEP]
cases s
[GOAL]
case nil
h : { data := [] } ≠ ""
⊢ toList { data := [] } = head { data := [] } :: toList (drop { data := [] } 1)
[PROOFSTEP]
simp only at h
[GOAL]
case cons
head✝ : Char
tail✝ : List Char
h : { data := head✝ :: tail✝ } ≠ ""
⊢ toList { data := head✝ :: tail✝ } = head { data := head✝ :: tail✝ } :: toList (drop { data := head✝ :: tail✝ } 1)
[PROOFSTEP]
rename_i c cs
[GOAL]
case cons
c : Char
cs : List Char
h : { data := c :: cs } ≠ ""
⊢ toList { data := c :: cs } = head { data := c :: cs } :: toList (drop { data := c :: cs } 1)
[PROOFSTEP]
simp only [toList, List.cons.injEq]
[GOAL]
case cons
c : Char
cs : List Char
h : { data := c :: cs } ≠ ""
⊢ c = head { data := c :: cs } ∧ cs = (drop { data := c :: cs } 1).data
[PROOFSTEP]
constructor <;> [rfl; simp [drop_eq]]
[GOAL]
case cons
c : Char
cs : List Char
h : { data := c :: cs } ≠ ""
⊢ c = head { data := c :: cs } ∧ cs = (drop { data := c :: cs } 1).data
[PROOFSTEP]
constructor
[GOAL]
case cons.left
c : Char
cs : List Char
h : { data := c :: cs } ≠ ""
⊢ c = head { data := c :: cs }
[PROOFSTEP]
rfl
[GOAL]
case cons.right
c : Char
cs : List Char
h : { data := c :: cs } ≠ ""
⊢ cs = (drop { data := c :: cs } 1).data
[PROOFSTEP]
simp [drop_eq]
[GOAL]
a b c : String
⊢ a ≤ b → b ≤ c → a ≤ c
[PROOFSTEP]
simp only [le_iff_toList_le]
[GOAL]
a b c : String
⊢ toList a ≤ toList b → toList b ≤ toList c → toList a ≤ toList c
[PROOFSTEP]
apply le_trans
[GOAL]
a b : String
⊢ a < b ↔ a ≤ b ∧ ¬b ≤ a
[PROOFSTEP]
simp only [lt_iff_toList_lt, le_iff_toList_le, lt_iff_le_not_le]
[GOAL]
a b : String
⊢ a ≤ b → b ≤ a → a = b
[PROOFSTEP]
simp only [le_iff_toList_le, ← toList_inj]
[GOAL]
a b : String
⊢ toList a ≤ toList b → toList b ≤ toList a → toList a = toList b
[PROOFSTEP]
apply le_antisymm
[GOAL]
a b : String
⊢ a ≤ b ∨ b ≤ a
[PROOFSTEP]
simp only [le_iff_toList_le]
[GOAL]
a b : String
⊢ toList a ≤ toList b ∨ toList b ≤ toList a
[PROOFSTEP]
apply le_total
[GOAL]
a b : String
⊢ compare a b = compareOfLessAndEq a b
[PROOFSTEP]
simp [compare, compareOfLessAndEq, toList, instLTString, List.instLTList, List.LT']
[GOAL]
a b : String
⊢ (if List.lt a.data b.data then Ordering.lt else if a = b then Ordering.eq else Ordering.gt) =
if List.Lex (fun x x_1 => x < x_1) a.data b.data then Ordering.lt else if a = b then Ordering.eq else Ordering.gt
[PROOFSTEP]
split_ifs
[GOAL]
case pos
a b : String
h✝¹ : List.lt a.data b.data
h✝ : List.Lex (fun x x_1 => x < x_1) a.data b.data
⊢ Ordering.lt = Ordering.lt
[PROOFSTEP]
simp [List.lt_iff_lex_lt] at *
[GOAL]
case pos
a b : String
h✝² : List.lt a.data b.data
h✝¹ : ¬List.Lex (fun x x_1 => x < x_1) a.data b.data
h✝ : a = b
⊢ False
[PROOFSTEP]
simp [List.lt_iff_lex_lt] at *
[GOAL]
case neg
a b : String
h✝² : List.lt a.data b.data
h✝¹ : ¬List.Lex (fun x x_1 => x < x_1) a.data b.data
h✝ : ¬a = b
⊢ False
[PROOFSTEP]
simp [List.lt_iff_lex_lt] at *
[GOAL]
case pos
a b : String
h✝² : ¬List.lt a.data b.data
h✝¹ : a = b
h✝ : List.Lex (fun x x_1 => x < x_1) a.data b.data
⊢ False
[PROOFSTEP]
simp [List.lt_iff_lex_lt] at *
[GOAL]
case neg
a b : String
h✝² : ¬List.lt a.data b.data
h✝¹ : a = b
h✝ : ¬List.Lex (fun x x_1 => x < x_1) a.data b.data
⊢ Ordering.eq = Ordering.eq
[PROOFSTEP]
simp [List.lt_iff_lex_lt] at *
[GOAL]
case pos
a b : String
h✝² : ¬List.lt a.data b.data
h✝¹ : ¬a = b
h✝ : List.Lex (fun x x_1 => x < x_1) a.data b.data
⊢ False
[PROOFSTEP]
simp [List.lt_iff_lex_lt] at *
[GOAL]
case neg
a b : String
h✝² : ¬List.lt a.data b.data
h✝¹ : ¬a = b
h✝ : ¬List.Lex (fun x x_1 => x < x_1) a.data b.data
⊢ Ordering.gt = Ordering.gt
[PROOFSTEP]
simp [List.lt_iff_lex_lt] at *
[GOAL]
case pos
a b : String
h✝² : ¬List.Lex (fun x x_1 => x < x_1) a.data b.data
h✝¹ : a = b
h✝ : List.Lex (fun x x_1 => x < x_1) a.data b.data
⊢ False
[PROOFSTEP]
contradiction
[GOAL]
case neg
a b : String
h✝² : ¬List.Lex (fun x x_1 => x < x_1) a.data b.data
h✝¹ : ¬a = b
h✝ : List.Lex (fun x x_1 => x < x_1) a.data b.data
⊢ False
[PROOFSTEP]
contradiction
[GOAL]
case pos
a b : String
h✝² : a = b
h✝¹ : List.Lex (fun x x_1 => x < x_1) a.data b.data
h✝ : ¬List.Lex (fun x x_1 => x < x_1) a.data b.data
⊢ False
[PROOFSTEP]
contradiction
[GOAL]
case pos
a b : String
h✝² : ¬a = b
h✝¹ : List.Lex (fun x x_1 => x < x_1) a.data b.data
h✝ : ¬List.Lex (fun x x_1 => x < x_1) a.data b.data
⊢ False
[PROOFSTEP]
contradiction
[GOAL]
l l' : List Char
h : asString l = asString l'
⊢ l = l'
[PROOFSTEP]
rw [← toList_inv_asString l, ← toList_inv_asString l', toList_inj, h]
[GOAL]
l : List Char
s : String
⊢ asString l = s ↔ l = toList s
[PROOFSTEP]
rw [← asString_inv_toList s, asString_inj, asString_inv_toList s]
|
informal statement If $G$ is a group and $a, x \in G$, prove that $C\left(x^{-1} a x\right)=x^{-1} C(a) x$formal statement theorem exercise_2_4_36 {a n : ℕ} (h : a > 1) :
n ∣ (a ^ n - 1).totient := |
[GOAL]
a b : ℕ
⊢ a ≠ b ↔ ↑a ≠ ↑b
[PROOFSTEP]
simp only [ne_eq, Int.cast_eq_cast_iff_Nat]
|
universes v
/-
matcher for the following patterns
```
| "hello" => _
| "world" => _
| a => _
``` -/
def matchString (C : String → Sort v) (s : String)
(h₁ : Unit → C "hello")
(h₂ : Unit → C "world")
(h₃ : ∀ s, C s)
: C s :=
dite (s = "hello")
(fun h => @Eq.ndrec _ _ (fun x => C x) (h₁ ()) _ h.symm)
(fun _ => dite (s = "world")
(fun h => @Eq.ndrec _ _ (fun x => C x) (h₂ ()) _ h.symm)
(fun _ => h₃ s))
theorem matchString.Eq1 (C : String → Sort v)
(h₁ : Unit → C "hello")
(h₂ : Unit → C "world")
(h₃ : ∀ s, C s)
: matchString C "hello" h₁ h₂ h₃ = h₁ () :=
difPos rfl
axiom neg1 : "world" ≠ "hello"
theorem matchString.Eq2 (C : String → Sort v)
(h₁ : Unit → C "hello")
(h₂ : Unit → C "world")
(h₃ : ∀ s, C s)
: matchString C "world" h₁ h₂ h₃ = h₂ () :=
have aux₁ : matchString C "world" h₁ h₂ h₃ = if h : "world" = "world" then @Eq.rec _ _ (fun x _ => C x) (h₂ ()) _ h.symm else h₃ "world" from difNeg neg1;
have aux₂ : (if h : "world" = "world" then @Eq.rec _ _ (fun x _ => C x) (h₂ ()) _ h.symm else h₃ "world" : C "world") = h₂ () from difPos rfl;
Eq.trans aux₁ aux₂
theorem matchString.Eq3 (C : String → Sort v)
(h₁ : Unit → C "hello")
(h₂ : Unit → C "world")
(h₃ : ∀ s, C s)
(s : String) (n₁ : s ≠ "hello") (n₂ : s ≠ "world")
: matchString C s h₁ h₂ h₃ = h₃ s :=
have aux₁ : matchString C s h₁ h₂ h₃ = if h : s = "world" then @Eq.rec _ _ (fun x _ => C x) (h₂ ()) _ h.symm else h₃ s from difNeg n₁;
have aux₂ : (if h : s = "world" then @Eq.rec _ _ (fun x _ => C x) (h₂ ()) _ h.symm else h₃ s : C s) = h₃ s from difNeg n₂;
Eq.trans aux₁ aux₂
|
import data.real.basic
theorem challenge3 :
(2 : ℝ) + 2 ≠ 5 :=
begin
norm_num
end
|
informal statement Let $X$ be a topological space and let $Y$ be a metric space. Let $f_{n}: X \rightarrow Y$ be a sequence of continuous functions. Let $x_{n}$ be a sequence of points of $X$ converging to $x$. Show that if the sequence $\left(f_{n}\right)$ converges uniformly to $f$, then $\left(f_{n}\left(x_{n}\right)\right)$ converges to $f(x)$.formal statement theorem exercise_22_2b {X : Type*} [topological_space X]
{A : set X} (r : X → A) (hr : continuous r) (h : ∀ x : A, r x = x) :
quotient_map r := |
import analysis.real tactic.norm_num algebra.group_power
theorem Q5a1 (S : set ℝ) : (∃ x : ℝ, x ∈ lower_bounds S)
↔ (∃ y : ℝ, y ∈ upper_bounds {t : ℝ | ∃ s ∈ S, t = -s }) := sorry
theorem Q5a2 (S : set ℝ) (x : ℝ) : is_glb S x ↔
is_lub {t : ℝ | ∃ s ∈ S, t = -s} (-x) := sorry
lemma Q5bhelper (S : set ℝ) (x₁ x₂ : ℝ) : is_glb S x₁ ∧ is_glb S x₂ → x₁ ≤ x₂ :=
begin
intro H,
have Hglb1 := H.left,
have Hlb1 := Hglb1.left,
have Hglb2 := H.right,
have H1 := Hglb2.right,
exact H1 _ Hlb1,
end
theorem Q5b (S : set ℝ) (x₁ x₂ : ℝ) : is_glb S x₁ ∧ is_glb S x₂ → x₁ = x₂ := sorry
theorem Q5c : (∀ S : set ℝ, (∃ w : ℝ, w ∈ S) → (∃ x : ℝ, x ∈ upper_bounds S) → ∃ y : ℝ, is_lub S y)
→ (∀ T : set ℝ, (∃ w₁ : ℝ, w₁ ∈ T) → (∃ x₁ : ℝ, x₁ ∈ lower_bounds T) → ∃ y₁ : ℝ, is_glb T y₁) := sorry
|
import data.real.basic
lemma mp (p q : Prop) :
p → (p → q) → q :=
λ hp hpq, hpq hp
|
informal statement Show that the subgroup of all rotations in a dihedral group is a maximal subgroup.formal statement theorem exercise_3_1_3a {A : Type*} [comm_group A] (B : subgroup A) :
∀ a b : A ⧸ B, a*b = b*a := |
informal statement Prove that characteristic subgroups are normal.formal statement theorem exercise_4_4_6a {G : Type*} [group G] (H : subgroup G)
[subgroup.characteristic H] : subgroup.normal H := |
import group_theory.subgroup
theorem cpge_groupe_9_a {G1 : Type*} [group G1] {G2 : Type*} [group G2]
(f : G1 →* G2) : ∀ (a : G1), ( (f a = 1) → (∀ (x : G1), f (x * a * x⁻¹) = 1)) := sorry
|
informal statement Prove that if an integer is the sum of two rational squares, then it is the sum of two integer squares.formal statement theorem exercise_8_3_6a {R : Type*} [ring R]
(hR : R = (gaussian_int ⧸ ideal.span ({⟨0, 1⟩} : set gaussian_int))) :
is_field R ∧ ∃ finR : fintype R, @card R finR = 2 := |
import data.real.basic tactic.ring tactic.tidy
/- Definitions -/
definition double (n : ℕ) : ℕ := n + n
#check double
#check double ∘ double
definition quadruple : ℕ → ℕ := double ∘ double
definition FLT : Prop :=
∀ n > 2, ∀ x y z, x^n + y^n = z^n → (x = 0 ∨ y = 0)
theorem Wiles : FLT :=
begin
unfold FLT,
intros,
sorry
end
--- --- --- --- --- --- --- --- --- --- --- --- --- ---
lemma transitive_imply (P Q R : Prop)
(P_imp_Q : P → Q)
(Q_imp_R : Q → R) :
P → R :=
begin
intro P_is_true,
apply Q_imp_R,
apply P_imp_Q,
assumption,
end
lemma transitive_imply' (P Q R : Prop)
(P_imp_Q : P → Q)
(Q_imp_R : Q → R) :
P → R := Q_imp_R ∘ P_imp_Q |
import linear_algebra.basic
universes u v w x
variables {R : Type u} [ring R]
variables {M₁ : Type v} [add_comm_group M₁] [module R M₁]
variables {M₂ : Type w} [add_comm_group M₂] [module R M₂]
variables {M₃ : Type x} [add_comm_group M₃] [module R M₃]
open linear_map
open submodule
lemma linear_map.ker_le_range_iff {f : M₁ →ₗ[R] M₂} {g : M₂ →ₗ[R] M₃} :
g.ker ≤ f.range ↔ f.range.mkq.comp g.ker.subtype = 0 :=
by rw [←range_le_ker_iff, ker_mkq, range_subtype]
/-⟨λ h, ker_eq_top.1 $ eq_top_iff'.2 $ λ x, mem_ker.2 $ by simpa using mem_range.1 (h x.2),
λ h,
begin
rw ←range_le_ker_iff at h,
rw ker_mkq at h,
rw range_subtype at h,
exact h,
end-
/-x hx,
begin
rw ←submodule.ker_mkq f.range,
apply mem_ker.2,
rw ←zero_apply x,
rw ←h,
--rw ←submodule.subtype_apply _ ⟨x, hx⟩,
exact mem_ker.2 (@linear_map.congr _ _ _ _ _ _ _ _
(comp (mkq (range f)) (submodule.subtype (ker g))) 0 ⟨x, hx⟩ h),-/
end⟩-/
|
-- Andreas, 2017-01-14, issue #2405 reported by m0davis
-- Instance not found due to regression introduced by
-- parameter-refinement.
-- {-# OPTIONS --show-implicit #-}
-- {-# OPTIONS -v tc.instance:70 #-}
-- {-# OPTIONS -v tc.meta.assign:40 #-}
-- {-# OPTIONS -v tc.conv:40 #-}
-- {-# OPTIONS -v tc.sig.param:100 #-}
postulate
R : Set → Set
S : (F : Set → Set) ⦃ _ : {A : Set} → R (F A) ⦄ → Set
module M1 (X : Set) where
postulate
F : Set → Set
instance Ri : {A : Set} → R (F A)
Si-works : S F ⦃ Ri ⦄
Si-test : S F
-- WAS:
-- No instance of type R (F A) was found in scope. -}
--
-- candidate:
-- Ri X : (A : Set) → R (F X A)
-- Ri 0 : Π Set λ A → R (F 1 0)
-- Ri 0 _A : R (F 0 (_A 1 0))
-- goal:
-- getMetaType
-- ? : (X A : Set) → R (F X A)
-- ? : Π Set λ X → Pi Set λ A → R (F 1 0)
-- ? : R (F A)
-- ? : R (F 1 0)
-- Should succeed.
|
/-
Copyright (c) 2021 Yourong Zang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yourong Zang
-/
import analysis.calculus.conformal.normed_space
import analysis.inner_product_space.conformal_linear_map
/-!
# Conformal maps between inner product spaces
A function between inner product spaces is which has a derivative at `x`
is conformal at `x` iff the derivative preserves inner products up to a scalar multiple.
-/
noncomputable theory
variables {E F : Type*}
variables [normed_add_comm_group E] [normed_add_comm_group F]
variables [inner_product_space ℝ E] [inner_product_space ℝ F]
open_locale real_inner_product_space
/-- A real differentiable map `f` is conformal at point `x` if and only if its
differential `fderiv ℝ f x` at that point scales every inner product by a positive scalar. -/
lemma conformal_at_iff' {f : E → F} {x : E} :
conformal_at f x ↔
∃ (c : ℝ), 0 < c ∧ ∀ (u v : E), ⟪fderiv ℝ f x u, fderiv ℝ f x v⟫ = c * ⟪u, v⟫ :=
by rw [conformal_at_iff_is_conformal_map_fderiv, is_conformal_map_iff]
/-- A real differentiable map `f` is conformal at point `x` if and only if its
differential `f'` at that point scales every inner product by a positive scalar. -/
lemma conformal_at_iff {f : E → F} {x : E} {f' : E →L[ℝ] F} (h : has_fderiv_at f f' x) :
conformal_at f x ↔ ∃ (c : ℝ), 0 < c ∧ ∀ (u v : E), ⟪f' u, f' v⟫ = c * ⟪u, v⟫ :=
by simp only [conformal_at_iff', h.fderiv]
/-- The conformal factor of a conformal map at some point `x`. Some authors refer to this function
as the characteristic function of the conformal map. -/
def conformal_factor_at {f : E → F} {x : E} (h : conformal_at f x) : ℝ :=
classical.some (conformal_at_iff'.mp h)
lemma conformal_factor_at_pos {f : E → F} {x : E} (h : conformal_at f x) :
0 < conformal_factor_at h :=
(classical.some_spec $ conformal_at_iff'.mp h).1
lemma conformal_factor_at_inner_eq_mul_inner' {f : E → F} {x : E}
(h : conformal_at f x) (u v : E) :
⟪(fderiv ℝ f x) u, (fderiv ℝ f x) v⟫ = (conformal_factor_at h : ℝ) * ⟪u, v⟫ :=
(classical.some_spec $ conformal_at_iff'.mp h).2 u v
lemma conformal_factor_at_inner_eq_mul_inner {f : E → F} {x : E} {f' : E →L[ℝ] F}
(h : has_fderiv_at f f' x) (H : conformal_at f x) (u v : E) :
⟪f' u, f' v⟫ = (conformal_factor_at H : ℝ) * ⟪u, v⟫ :=
(H.differentiable_at.has_fderiv_at.unique h) ▸ conformal_factor_at_inner_eq_mul_inner' H u v
|
opaque f : Nat → Nat
opaque g : Nat → Nat
namespace Foo
@[scoped simp] axiom ax1 (x : Nat) : f (g x) = x
@[scoped simp] axiom ax2 (x : Nat) : g (g x) = g x
end Foo
theorem ex1 : f (g (g (g x))) = x := by
simp -- does not use ax1 and ax2
simp [Foo.ax1, Foo.ax2]
theorem ex2 : f (g (g (g x))) = x :=
have h₁ : f (g (g (g x))) = f (g x) := by simp; /- try again with `Foo` scoped lemmas -/ open Foo in simp
have h₂ : f (g x) = x := by simp; open Foo in simp
Eq.trans h₁ h₂
-- open Foo in simp -- works
theorem ex3 : f (g (g (g x))) = x := by
simp
simp [Foo.ax1, Foo.ax2]
open Foo in
theorem ex4 : f (g (g (g x))) = x := by
simp
theorem ex5 : f (g (g (g x))) = x ∧ f (g x) = x := by
apply And.intro
{ simp; open Foo in simp }
{ simp; open Foo in simp }
|
theorem ex1 (p q r : Prop) (h1 : p ∨ q) (h2 : p → q) : q := by
theorem ex2 (p q r : Prop) (h1 : p ∨ q) (h2 : p → q) : q := by
cases h1
case inl =>
|
[STATEMENT]
lemma ensures_simple:
"\<lbrakk> \<turnstile> $P \<and> N \<longrightarrow> P` \<or> Q`;
\<turnstile> ($P \<and> N) \<and> A \<longrightarrow> Q`
\<rbrakk> \<Longrightarrow> \<turnstile> \<box>N \<and> \<box>\<diamond>A \<longrightarrow> (P \<leadsto> Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<lbrakk>\<turnstile> $P \<and> N \<longrightarrow> P$ \<or> Q$; \<turnstile> ($P \<and> N) \<and> A \<longrightarrow> Q$\<rbrakk> \<Longrightarrow> \<turnstile> \<box>N \<and> \<box>\<diamond>A \<longrightarrow> (P \<leadsto> Q)
[PROOF STEP]
apply clarsimp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>sigma. \<lbrakk>\<turnstile> $P \<and> N \<longrightarrow> P$ \<or> Q$; \<turnstile> ($P \<and> N) \<and> A \<longrightarrow> Q$; sigma \<Turnstile> \<box>N; sigma \<Turnstile> \<box>\<diamond>A\<rbrakk> \<Longrightarrow> sigma \<Turnstile> P \<leadsto> Q
[PROOF STEP]
apply (erule (2) ensures [temp_use])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. \<And>sigma. \<lbrakk>\<turnstile> ($P \<and> N) \<and> A \<longrightarrow> Q$; sigma \<Turnstile> \<box>N; sigma \<Turnstile> \<box>\<diamond>A\<rbrakk> \<Longrightarrow> sigma \<Turnstile> \<box>(\<box>P \<longrightarrow> \<diamond>A)
[PROOF STEP]
apply (force elim!: STL4E [temp_use])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done |
import data.real.basic
import data.polynomial.basic
import data.polynomial.ring_division
import data.complex.basic
theorem USAMO_Problem_3_1977 (a b : ℂ):
(a ∈ polynomial.roots ((polynomial.monomial 4 (1:ℂ ) ) + (polynomial.monomial 3 (1:ℂ) ) - 1) ∧
b ∈ polynomial.roots ((polynomial.monomial 4 (1:ℂ) ) + (polynomial.monomial 3 (1:ℂ) ) - 1)) →
(a*b) ∈ polynomial.roots (polynomial.monomial 6 (1:ℂ ) +
polynomial.monomial 4 (1:ℂ ) +
polynomial.monomial 3 (1:ℂ ) -
polynomial.monomial 2 (1:ℂ ) -1)
:= sorry
|
example : ∃ a : ℕ, 5 = a :=
begin
apply exists.intro,
reflexivity
end
|
/-
Copyright (c) 2022 Michael Stoll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Stoll
! This file was ported from Lean 3 source module data.fin.tuple.bubble_sort_induction
! leanprover-community/mathlib commit 50832daea47b195a48b5b33b1c8b2162c48c3afc
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Data.Fin.Tuple.Sort
import Mathbin.Data.Fintype.Perm
import Mathbin.Order.WellFounded
/-!
# "Bubble sort" induction
> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
> Any changes to this file require a corresponding PR to mathlib4.
We implement the following induction principle `tuple.bubble_sort_induction`
on tuples with values in a linear order `α`.
Let `f : fin n → α` and let `P` be a predicate on `fin n → α`. Then we can show that
`f ∘ sort f` satisfies `P` if `f` satisfies `P`, and whenever some `g : fin n → α`
satisfies `P` and `g i > g j` for some `i < j`, then `g ∘ swap i j` also satisfies `P`.
We deduce it from a stronger variant `tuple.bubble_sort_induction'`, which
requires the assumption only for `g` that are permutations of `f`.
The latter is proved by well-founded induction via `well_founded.induction_bot'`
with respect to the lexicographic ordering on the finite set of all permutations of `f`.
-/
namespace Tuple
#print Tuple.bubble_sort_induction' /-
/-- *Bubble sort induction*: Prove that the sorted version of `f` has some property `P`
if `f` satsifies `P` and `P` is preserved on permutations of `f` when swapping two
antitone values. -/
theorem bubble_sort_induction' {n : ℕ} {α : Type _} [LinearOrder α] {f : Fin n → α}
{P : (Fin n → α) → Prop} (hf : P f)
(h :
∀ (σ : Equiv.Perm (Fin n)) (i j : Fin n),
i < j → (f ∘ σ) j < (f ∘ σ) i → P (f ∘ σ) → P (f ∘ σ ∘ Equiv.swap i j)) :
P (f ∘ sort f) :=
by
letI := @Preorder.lift _ (Lex (Fin n → α)) _ fun σ : Equiv.Perm (Fin n) => toLex (f ∘ σ)
refine'
@WellFounded.induction_bot' _ _ _ (@Finite.Preorder.wellFounded_lt (Equiv.Perm (Fin n)) _ _)
(Equiv.refl _) (sort f) P (fun σ => f ∘ σ) (fun σ hσ hfσ => _) hf
obtain ⟨i, j, hij₁, hij₂⟩ := antitone_pair_of_not_sorted' hσ
exact ⟨σ * Equiv.swap i j, Pi.lex_desc hij₁ hij₂, h σ i j hij₁ hij₂ hfσ⟩
#align tuple.bubble_sort_induction' Tuple.bubble_sort_induction'
-/
#print Tuple.bubble_sort_induction /-
/-- *Bubble sort induction*: Prove that the sorted version of `f` has some property `P`
if `f` satsifies `P` and `P` is preserved when swapping two antitone values. -/
theorem bubble_sort_induction {n : ℕ} {α : Type _} [LinearOrder α] {f : Fin n → α}
{P : (Fin n → α) → Prop} (hf : P f)
(h : ∀ (g : Fin n → α) (i j : Fin n), i < j → g j < g i → P g → P (g ∘ Equiv.swap i j)) :
P (f ∘ sort f) :=
bubble_sort_induction' hf fun σ => h _
#align tuple.bubble_sort_induction Tuple.bubble_sort_induction
-/
end Tuple
|
informal statement Let $H \leq K \leq G$. Prove that $|G: H|=|G: K| \cdot|K: H|$ (do not assume $G$ is finite).formal statement theorem exercise_3_2_11 {G : Type*} [group G] {H K : subgroup G}
(hHK : H ≤ K) :
H.index = K.index * H.relindex K := |
universe u
variable {α : Type u}
def split : List α → List α × List α
| [] => ([], [])
| [a] => ([a], [])
| a::b::as => (a :: (split as).1, b :: (split as).2)
theorem ex1 : split [1, 2, 3, 4, 5] = ([1, 3, 5], [2, 4]) :=
rfl
|
{-# OPTIONS --erased-cubical #-}
module Erased-cubical-Open-public.Erased (_ : Set₁) where
postulate
A : Set
|
theory Scratch
imports Main
begin
lemma "1=1" by simp
end |
universes u v
inductive Vec2 (α : Type u) (β : Type v) : Nat → Type (max u v)
| nil : Vec2 α β 0
| cons : α → β → forall {n}, Vec2 α β n → Vec2 α β (n+1)
inductive Fin2 : Nat → Type
| zero (n : Nat) : Fin2 (n+1)
| succ {n : Nat} (s : Fin2 n) : Fin2 (n+1)
theorem test1 {α β} {n} (a₁ a₂ : α) (b₁ b₂ : β) (v w : Vec2 α β n) (h : Vec2.cons a₁ b₁ v = Vec2.cons a₂ b₂ w) : a₁ = a₂ :=
by {
injection h;
assumption
}
theorem test2 {α β} {n} (a₁ a₂ : α) (b₁ b₂ : β) (v w : Vec2 α β n) (h : Vec2.cons a₁ b₁ v = Vec2.cons a₂ b₂ w) : v = w :=
by {
injection h with h1 h2 h3 h4;
assumption
}
theorem test3 {α β} {n} (a₁ a₂ : α) (b₁ b₂ : β) (v w : Vec2 α β n) (h : Vec2.cons a₁ b₁ v = Vec2.cons a₂ b₂ w) : v = w :=
by {
injection h with _ _ _ h4;
exact h4
}
theorem test4 {α} (v : Fin2 0) : α :=
by cases v
def test5 {α β} {n} (v : Vec2 α β (n+1)) : α := by
cases v with
| cons h1 h2 n tail => exact h1
def test6 {α β} {n} (v : Vec2 α β (n+2)) : α := by
cases v with
| cons h1 h2 n tail => exact h1
|
def f (a : Array Nat) (i : Nat) (v : Nat) (h : i < a.size) : Array Nat :=
a.set ⟨i, h⟩ (a.get ⟨i, h⟩ + v)
set_option pp.proofs true
theorem ex1 (h₃ : i = j) : f a i (0 + v) h₁ = f a j v h₂ := by
simp
trace_state
simp [h₃]
theorem ex2 (h₃ : i = j) : f a (0 + i) (0 + v) h₁ = f a j v h₂ := by
simp
trace_state
simp [h₃]
theorem ex3 (h₃ : i = j) : f a (0 + i) (0 + v) h₁ = f a j v h₂ := by
simp [h₃]
|
@[simp] theorem liftOn_mk (a : α) (f : α → γ) (h : ∀ a₁ a₂, r a₁ a₂ → f a₁ = f a₂) :
Quot.liftOn (Quot.mk r a) f h = f a := rfl
theorem eq_iff_true_of_subsingleton [Subsingleton α] (x y : α) : x = y ↔ True :=
iff_true _ ▸ Subsingleton.elim ..
section attribute [simp] eq_iff_true_of_subsingleton end
@[simp] theorem PUnit.default_eq_unit : (default : PUnit) = PUnit.unit := rfl
set_option trace.Meta.Tactic.simp.discharge true
set_option trace.Meta.Tactic.simp.unify true
set_option trace.Meta.Tactic.simp.rewrite true
example : (default : PUnit) = x := by simp
|
section {* \isaheader{Generic Compare Algorithms} *}
theory Gen_Comp
imports
"../Intf/Intf_Comp"
"../../../Automatic_Refinement/Automatic_Refinement"
begin
subsection {* Order for Product *}
(* TODO: Optimization? Or only go via prod_cmp? *)
lemma autoref_prod_cmp_dflt_id[autoref_rules_raw]:
"(dflt_cmp op \<le> op <, dflt_cmp op \<le> op <) \<in>
\<langle>Id,Id\<rangle>prod_rel \<rightarrow> \<langle>Id,Id\<rangle>prod_rel \<rightarrow> Id"
by auto
lemma gen_prod_cmp_dflt[autoref_rules_raw]:
assumes PRIO_TAG_GEN_ALGO
assumes "GEN_OP cmp1 (dflt_cmp op \<le> op <) (R1 \<rightarrow> R1 \<rightarrow> Id)"
assumes "GEN_OP cmp2 (dflt_cmp op \<le> op <) (R2 \<rightarrow> R2 \<rightarrow> Id)"
shows "(cmp_prod cmp1 cmp2, dflt_cmp op \<le> op <) \<in>
\<langle>R1,R2\<rangle>prod_rel \<rightarrow> \<langle>R1,R2\<rangle>prod_rel \<rightarrow> Id"
proof -
have E: "dflt_cmp op \<le> op <
= cmp_prod (dflt_cmp op \<le> op <) (dflt_cmp op \<le> op <)"
by (auto simp: dflt_cmp_def prod_less_def prod_le_def intro!: ext)
show ?thesis
using assms
unfolding autoref_tag_defs E
by parametricity
qed
end
|
--
/-
This example demonstratea that when we are using `nativeDecide`,
we are also trusting the correctness of `implementedBy` annotations,
foreign functions (i.e., `[extern]` annotations), etc.
-/
def g (b : Bool) := false
/-
The following `implementedBy` is telling the compiler
"trust me, `g` does implement `f`"
which is clearly false in this example.
-/
@[implementedBy g]
def f (b : Bool) := b
theorem fConst (b : Bool) : f b = false :=
match b with
| true =>
/- The following `nativeDecide` is going to use `g` to evaluate `f`
because of the `implementedBy` directive. -/
have : (f true) = false := by nativeDecide
this
| false => rfl
theorem trueEqFalse : true = false :=
have h₁ : f true = true := rfl;
have h₂ : f true = false := fConst true;
Eq.trans h₁.symm h₂
/-
We managed to prove `False` using the unsound annotation `implementedBy` above.
-/
theorem unsound : False :=
Bool.noConfusion trueEqFalse
#print axioms unsound -- axiom 'Lean.ofReduceBool' is listed
|
[GOAL]
⊢ DivisionRing ℚ
[PROOFSTEP]
infer_instance
|
informal statement Show that there are infinitely many primes congruent to $-1$ modulo 6 .formal statement theorem exercise_3_1 : infinite {p : primes // p ≡ -1 [ZMOD 6]} := |
/-|
Hello World!
-/
#print "Hello World!"
/-|
A literate comment!
-/
theorem exampleTheorem (p q : Prop) (hp : p) (hq : q) : p ∧ q ∧ p := by
apply And.intro
. exact hp
. sorry |
class Preorder (α : Type u) extends LE α where
le_refl (a : α) : a ≤ a
le_trans {a b c : α} : a ≤ b → b ≤ c → a ≤ c
instance {α : Type u} {β : α → Type v} [(a : α) → Preorder (β a)] : Preorder ((a : α) → β a) where
le f g := ∀ a, f a ≤ g a
le_refl f := fun a => Preorder.le_refl (f a)
le_trans := fun h₁ h₂ a => Preorder.le_trans (h₁ a) (h₂ a)
-- In Lean 3, we defined `monotone` using the strict implicit notation `{{ ... }}`.
-- Implicit lambdas in Lean 4 allow us to use the regular `{...}`
def Monotone [Preorder α] [Preorder β] (f : α → β) :=
∀ {a b}, a ≤ b → f a ≤ f b
theorem monotone_id [Preorder α] : Monotone (α := α) id :=
fun h => h
theorem monotone_id' [Preorder α] : Monotone (α := α) id :=
@fun a b h => h -- `@` disables implicit lambdas
theorem monotone_id'' [Preorder α] : Monotone (α := α) id :=
fun {a b} (h : a ≤ b) => h -- `{a b}` disables implicit lambdas
theorem monotone_const [Preorder α] [Preorder β] (b : β) : Monotone (fun a : α => b) :=
fun _ => Preorder.le_refl b
theorem monotone_comp [Preorder α] [Preorder β] [Preorder γ] {g : β → γ} {f : α → β} (m_g : Monotone g) (m_f : Monotone f) : Monotone (g ∘ f) :=
fun h => m_g (m_f h)
theorem monotone_fun [Preorder α] [Preorder γ] {f : α → β → γ} (m : (b : β) → Monotone (fun a => f a b)) : Monotone f :=
fun h b => m b h
theorem ex [Preorder α] {f g h : α → α} (m_h : Monotone h) (m_g : Monotone g) (m_f : Monotone f) : Monotone (h ∘ g ∘ f) :=
monotone_comp m_h (monotone_comp m_g m_f) -- implicit lambdas in action here
|
From stdpp Require Import base tactics.
(** Test parsing of variants of [(≡)] notation. *)
Lemma test_equiv_annot_sections `{!Equiv A, !Equivalence (≡@{A})} (x : A) :
x ≡@{A} x ∧ (≡@{A}) x x ∧ (x ≡.) x ∧ (.≡ x) x ∧
((x ≡@{A} x)) ∧ ((≡@{A})) x x ∧ ((x ≡.)) x ∧ ((.≡ x)) x ∧
( x ≡@{A} x) ∧ ( x ≡.) x ∧
(x ≡@{A} x ) ∧ (≡@{A} ) x x ∧ (.≡ x ) x.
Proof. naive_solver. Qed.
|
import LeanCodePrompts.FirstTacticFinder
import Mathlib.Tactic.Basic
import Mathlib.Tactic.Use
import Mathlib
-- example : ∀ n : ℕ, ∃ m : ℕ, n < 2 * m + 1 := by
-- repeat (aide_lookahead)
-- repeat (sorry)
set_option trace.Translate.info true
example : ∀ n : ℕ, ∃ m : ℕ, n < 2 * m + 1 := by
show_tactic_prompt
aide
aide
aide
repeat (sorry)
|
informal statement Show that if $X$ is normal, every pair of disjoint closed sets have neighborhoods whose closures are disjoint.formal statement theorem exercise_32_1 {X : Type*} [topological_space X]
(hX : normal_space X) (A : set X) (hA : is_closed A) :
normal_space {x // x ∈ A} := |
theorem P_implies_P (P : Prop) : P → P :=
begin
intro HP,
exact HP
end
|
import Mathlib.Data.Nat.Basic
theorem rangeDecompose (start mid stop : ℕ) (hs : start ≤ mid ∧ mid ≤ stop)
{f : ℕ → β → Id (ForInStep β)} :
STD.forIn (mkRange' start stop) init f =
STD.forIn (mkRange' mid stop) (Id.run (STD.forIn (mkRange' start mid) init f)) f := by
sorry |
import help data.nat.prime
open nat
theorem Euclid (n : ℕ) : ∃ p ≥ n, prime p :=
begin
let N := n.fact + 1,
let p := min_fac N,
use_this p,
have p_is_prime : prime p := min_fac_prime _,
split,
show p ≥ n,
by_contradiction,
have key_fact : p ∣ n.fact := dvd_fact _ _,
have oops : p ∣ 1,
all_goals { auto },
end |
lemma lt_aux_one (a b : mynat) : a ≤ b ∧ ¬ (b ≤ a) → succ a ≤ b :=
begin
intro h,
cases h with h1 h2,
cases h1 with c h1,
cases c,
rw add_zero at h1,
rw h1 at h2,
exfalso,
exact h2 (le_refl a),
rwa [h1, add_succ],
apply succ_le_succ,
use c,
refl,
end
|
(* Title: HOL/ex/PresburgerEx.thy
Author: Amine Chaieb, TU Muenchen
*)
section {* Some examples for Presburger Arithmetic *}
theory PresburgerEx
imports Presburger
begin
lemma "\<And>m n ja ia. \<lbrakk>\<not> m \<le> j; \<not> (n::nat) \<le> i; (e::nat) \<noteq> 0; Suc j \<le> ja\<rbrakk> \<Longrightarrow> \<exists>m. \<forall>ja ia. m \<le> ja \<longrightarrow> (if j = ja \<and> i = ia then e else 0) = 0" by presburger
lemma "(0::nat) < emBits mod 8 \<Longrightarrow> 8 + emBits div 8 * 8 - emBits = 8 - emBits mod 8"
by presburger
lemma "(0::nat) < emBits mod 8 \<Longrightarrow> 8 + emBits div 8 * 8 - emBits = 8 - emBits mod 8"
by presburger
theorem "(\<forall>(y::int). 3 dvd y) ==> \<forall>(x::int). b < x --> a \<le> x"
by presburger
theorem "!! (y::int) (z::int) (n::int). 3 dvd z ==> 2 dvd (y::int) ==>
(\<exists>(x::int). 2*x = y) & (\<exists>(k::int). 3*k = z)"
by presburger
theorem "!! (y::int) (z::int) n. Suc(n::nat) < 6 ==> 3 dvd z ==>
2 dvd (y::int) ==> (\<exists>(x::int). 2*x = y) & (\<exists>(k::int). 3*k = z)"
by presburger
theorem "\<forall>(x::nat). \<exists>(y::nat). (0::nat) \<le> 5 --> y = 5 + x "
by presburger
text{*Slow: about 7 seconds on a 1.6GHz machine.*}
theorem "\<forall>(x::nat). \<exists>(y::nat). y = 5 + x | x div 6 + 1= 2"
by presburger
theorem "\<exists>(x::int). 0 < x"
by presburger
theorem "\<forall>(x::int) y. x < y --> 2 * x + 1 < 2 * y"
by presburger
theorem "\<forall>(x::int) y. 2 * x + 1 \<noteq> 2 * y"
by presburger
theorem "\<exists>(x::int) y. 0 < x & 0 \<le> y & 3 * x - 5 * y = 1"
by presburger
theorem "~ (\<exists>(x::int) (y::int) (z::int). 4*x + (-6::int)*y = 1)"
by presburger
theorem "\<forall>(x::int). b < x --> a \<le> x"
apply (presburger elim)
oops
theorem "~ (\<exists>(x::int). False)"
by presburger
theorem "\<forall>(x::int). (a::int) < 3 * x --> b < 3 * x"
apply (presburger elim)
oops
theorem "\<forall>(x::int). (2 dvd x) --> (\<exists>(y::int). x = 2*y)"
by presburger
theorem "\<forall>(x::int). (2 dvd x) --> (\<exists>(y::int). x = 2*y)"
by presburger
theorem "\<forall>(x::int). (2 dvd x) = (\<exists>(y::int). x = 2*y)"
by presburger
theorem "\<forall>(x::int). ((2 dvd x) = (\<forall>(y::int). x \<noteq> 2*y + 1))"
by presburger
theorem "~ (\<forall>(x::int).
((2 dvd x) = (\<forall>(y::int). x \<noteq> 2*y+1) |
(\<exists>(q::int) (u::int) i. 3*i + 2*q - u < 17)
--> 0 < x | ((~ 3 dvd x) &(x + 8 = 0))))"
by presburger
theorem "~ (\<forall>(i::int). 4 \<le> i --> (\<exists>x y. 0 \<le> x & 0 \<le> y & 3 * x + 5 * y = i))"
by presburger
theorem "\<forall>(i::int). 8 \<le> i --> (\<exists>x y. 0 \<le> x & 0 \<le> y & 3 * x + 5 * y = i)"
by presburger
theorem "\<exists>(j::int). \<forall>i. j \<le> i --> (\<exists>x y. 0 \<le> x & 0 \<le> y & 3 * x + 5 * y = i)"
by presburger
theorem "~ (\<forall>j (i::int). j \<le> i --> (\<exists>x y. 0 \<le> x & 0 \<le> y & 3 * x + 5 * y = i))"
by presburger
text{*Slow: about 5 seconds on a 1.6GHz machine.*}
theorem "(\<exists>m::nat. n = 2 * m) --> (n + 1) div 2 = n div 2"
by presburger
text{* This following theorem proves that all solutions to the
recurrence relation $x_{i+2} = |x_{i+1}| - x_i$ are periodic with
period 9. The example was brought to our attention by John
Harrison. It does does not require Presburger arithmetic but merely
quantifier-free linear arithmetic and holds for the rationals as well.
Warning: it takes (in 2006) over 4.2 minutes! *}
lemma "\<lbrakk> x3 = abs x2 - x1; x4 = abs x3 - x2; x5 = abs x4 - x3;
x6 = abs x5 - x4; x7 = abs x6 - x5; x8 = abs x7 - x6;
x9 = abs x8 - x7; x10 = abs x9 - x8; x11 = abs x10 - x9 \<rbrakk>
\<Longrightarrow> x1 = x10 & x2 = (x11::int)"
by arith
end
|
informal statement Show that any subgroup of order $p^{n-1}$ in a group $G$ of order $p^n$ is normal in $G$.formal statement theorem exercise_4_1_19 : infinite {x : quaternion ℝ | x^2 = -1} := |
import tactic
variable X : Type
theorem reflexive_of_symmetric_transitive_and_connected
(r : X → X → Prop)
(h_symm : ∀ x y : X, r x y → r y x)
(h_trans : ∀ x y z : X, r x y → r y z → r x z)
(h_connected : ∀ x, ∃ y, r x y)
: (∀ x : X, r x x) :=
begin
sorry,
end |
module Main
mutual
%inline
is_even : Int -> Int
is_even n =
if n == 0 then 1 else is_odd $ n-1
is_odd : Int -> Int
is_odd n =
if n == 0 then 0 else is_even $ n-1
main : JS_IO ()
main = do
putStr' $ show $ is_even 100001
|
informal statement Define $\wedge(n)=\log p$ if $n$ is a power of $p$ and zero otherwise. Prove that $\sum_{A \mid n} \mu(n / d) \log d$ $=\wedge(n)$.formal statement theorem exercise_3_1 : infinite {p : primes // p ≡ -1 [ZMOD 6]} := |
lemma contrapositive2 (P Q : Prop) : (¬ Q → ¬ P) → (P → Q) :=
begin
by_cases p : P; by_cases q : Q,
intros h p2,
exact q,
repeat { tauto! },
end |
informal statement If $C_{0}+\frac{C_{1}}{2}+\cdots+\frac{C_{n-1}}{n}+\frac{C_{n}}{n+1}=0,$ where $C_{0}, \ldots, C_{n}$ are real constants, prove that the equation $C_{0}+C_{1} x+\cdots+C_{n-1} x^{n-1}+C_{n} x^{n}=0$ has at least one real root between 0 and 1.formal statement theorem exercise_5_6
{f : ℝ → ℝ}
(hf1 : continuous f)
(hf2 : ∀ x, differentiable_at ℝ f x)
(hf3 : f 0 = 0)
(hf4 : monotone (deriv f)) :
monotone_on (λ x, f x / x) (set.Ioi 0) := |
theorem tst0 (x : Nat) : x + 0 = x + 0 :=
by {
generalize x + 0 = y;
exact (Eq.refl y)
}
theorem tst1 (x : Nat) : x + 0 = x + 0 :=
by {
generalize h : x + 0 = y;
exact (Eq.refl y)
}
theorem tst2 (x y w : Nat) (h : y = w) : (x + x) + w = (x + x) + y :=
by {
generalize h' : x + x = z;
subst y;
exact Eq.refl $ z + w
}
theorem tst3 (x y w : Nat) (h : x + x = y) : (x + x) + (x+x) = (x + x) + y :=
by {
generalize h' : x + x = z;
subst z;
subst y;
exact rfl
}
theorem tst4 (x y w : Nat) (h : y = w) : (x + x) + w = (x + x) + y :=
by {
generalize h' : x + y = z; -- just add equality
subst h;
exact rfl
}
|
open import Relation.Binary.Core
module TreeSort.Impl2.Correctness.Order {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_)
(trans≤ : Transitive _≤_) where
open import BBSTree _≤_
open import BBSTree.Properties _≤_ trans≤
open import Data.List
open import Function using (_∘_)
open import List.Sorted _≤_
open import TreeSort.Impl2 _≤_ tot≤
theorem-treeSort-sorted : (xs : List A) → Sorted (flatten (treeSort xs))
theorem-treeSort-sorted = lemma-bbst-sorted ∘ treeSort
|
abbrev M := ExceptT String <| StateT Nat Id
def f (xs : List Nat) : M Unit := do
for x in xs do
if x == 0 then
throw "contains zero"
#eval f [1, 2, 3] |>.run' 0
#eval f [1, 0, 3] |>.run' 0
theorem ex1 : (f [1, 2, 3] |>.run' 0) = Except.ok () :=
rfl
theorem ex2 : (f [1, 0, 3] |>.run' 0) = Except.error "contains zero" :=
rfl
universe u
abbrev N := ExceptT (ULift.{u} String) Id
def idM {α : Type u} (a : α) : N α :=
pure a
def checkEq {α : Type u} [BEq α] [ToString α] (a b : α) : N PUnit := do
unless a == b do
throw (ULift.up s!"{a} is not equal to {b}")
def g {α : Type u} [BEq α] [ToString α] (xs : List α) (a : α) : N PUnit := do
for x in xs do
let a ← idM a
checkEq x a
#eval g [1, (2:Nat), 3] 1 |>.run
|
lemma zero_le (a : mynat) : 0 ≤ a :=
begin
rw le_iff_exists_add,
use a,
rwa zero_add,
end
|
/-
# Advanced proposition world.
## Level 3: and_trans.
-/
/- Lemma
If $P$, $Q$ and $R$ are true/false statements, then $P\land Q$ and
$Q\land R$ together imply $P\land R$.
-/
lemma and_trans (P Q R : Prop) : P ∧ Q → Q ∧ R → P ∧ R :=
begin
intro hpq,
intro hqr,
cases hpq with p q,
cases hqr with q' r,
split,
assumption,
assumption,
end
|
informal statement Show that $\int_0^1 \log(\sin \pi x) dx = - \log 2$.formal statement theorem exercise_3_9 : ∫ x in 0..1, real.log (real.sin (real.pi * x)) = - real.log 2 := |
module ModusPonens where
modusPonens : ∀ {P Q : Set} → (P → Q) → P → Q
modusPonens x = x
|
[STATEMENT]
lemma HIm_nth [simp]:
"HIm x $ 1 = Im1 x" "HIm x $ 2 = Im2 x" "HIm x $ 3 = Im3 x" "HIm x $ 4 = Im4 x"
"HIm x $ 5 = Im5 x" "HIm x $ 6 = Im6 x" "HIm x $ 7 = Im7 x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (HIm x $ 1 = Im1 x &&& HIm x $ 2 = Im2 x &&& HIm x $ 3 = Im3 x) &&& (HIm x $ 4 = Im4 x &&& HIm x $ 5 = Im5 x) &&& HIm x $ 6 = Im6 x &&& HIm x $ 7 = Im7 x
[PROOF STEP]
by (simp_all add: HIm_def) |
/-
Copyright (c) 2021 OpenAI. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kunhao Zheng, Stanislas Polu, David Renshaw, OpenAI GPT-f
-/
import mathzoo.imports.miniF2F
open_locale nat rat real big_operators topological_space
/--
Suppose that $f(x+3)=3x^2 + 7x + 4$ and $f(x)=ax^2 + bx + c$. What is $a+b+c$?
Answer: $2$
--/
theorem amc12a_2009_p9
(a b c : ℝ)
(f : ℝ → ℝ)
(h₀ : ∀ x, f (x + 3) = 3 * x^2 + 7 * x + 4)
(h₁ : ∀ x, f x = a * x^2 + b * x + c) :
a + b + c = 2 :=
begin
simp [*, pow_succ'] at *,
linarith [h₀ 0, h₀ 1, h₀ 2],
end |
theorem tst1 (x y z : Nat) : y = z → x = x → x = y → x = z :=
by {
intros h1 h2 h3;
revert h2;
intro h2;
exact Eq.trans h3 h1
}
theorem tst2 (x y z : Nat) : y = z → x = x → x = y → x = z :=
by {
intros h1 h2 h3;
revert y;
intros y hb ha;
exact Eq.trans ha hb
}
theorem tst3 (x y z : Nat) : y = z → x = x → x = y → x = z := by
intros
revert ‹x = y›
intro ha
exact Eq.trans ha ‹y = z›
|
universe u
theorem instForAll {A : Type u} {f : A → Prop} {a : A} :
(forall a' : A, f a') → f a := by
intro h
exact h a
theorem instEqual₁ {A : Type u} {P : A → Prop} {t : A} :
(forall x : A, x = t → P x) → P t := by
intro h
exact h t rfl
theorem instEqual₂ {A : Type u} {P : A → Prop} {t : A} :
P t → (forall x : A, x = t → P x) := by
intros h x r
rewrite [r]
exact h
theorem instEqual {A : Type u} {P : A → Prop} {t : A} :
(forall x : A, x = t → P x) ↔ P t := ⟨instEqual₁, instEqual₂⟩
|
lemma ne_succ_self (n : ℕ) : n ≠ nat.succ n :=
begin
end |
import data.real.basic
import data.set.intervals.unordered_interval
theorem USAMO_Problem_3_1993 (f : ℝ -> ℝ) [f ≥ 0] [f(1) = 1]:
(∀ x y : ℝ, (x ∈ (set.interval (0 : ℝ) (1: ℝ)) ∧ y ∈ (set.interval (0 : ℝ) (1: ℝ))) →
x+y ∈ (set.interval (0 : ℝ) (1: ℝ)) → f(x) + f(y) ≤ f(x+y)) →
(∀ x : ℝ, x ∈ (set.interval (0 : ℝ) (1: ℝ)) → f(x) >= 2*x)
∧ (¬ (∃ c : ℝ, c < 2 ∧ (∀ x : ℝ, x ∈ (set.interval (0 : ℝ) (1: ℝ)) → f(x) >= c*x)))
:= sorry
|
informal statement Prove that $\cos 1^{\circ}$ is algebraic over $\mathbb{Q}$.formal statement theorem exercise_5_3_10 : is_algebraic ℚ (cos (real.pi / 180)) := |
lemma convex_prod: assumes "\<And>i. i \<in> Basis \<Longrightarrow> convex {x. P i x}" shows "convex {x. \<forall>i\<in>Basis. P i (x\<bullet>i)}" |
section
variables (P Q : Prop)
theorem my_theorem : P ∧ Q → Q ∧ P :=
assume h : P ∧ Q,
have P, from and.left h,
have Q, from and.right h,
show Q ∧ P, from and.intro ‹Q› ‹P›
end
|
informal statement Let $F = \mathbb{Z}_p$ be the field of integers $\mod p$, where $p$ is a prime, and let $q(x) \in F[x]$ be irreducible of degree $n$. Show that $F[x]/(q(x))$ is a field having at exactly $p^n$ elements.formal statement theorem exercise_4_5_25 {p : ℕ} (hp : nat.prime p) :
irreducible (∑ i : finset.range p, X ^ p : polynomial ℚ) := |
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Kenny Lau
-/
import data.finset.basic
/-!
# Finsets of ordered types
-/
universes u v w
variables {α : Type u}
theorem directed.finset_le {r : α → α → Prop} [is_trans α r]
{ι} [hι : nonempty ι] {f : ι → α} (D : directed r f) (s : finset ι) :
∃ z, ∀ i ∈ s, r (f i) (f z) :=
show ∃ z, ∀ i ∈ s.1, r (f i) (f z), from
multiset.induction_on s.1 (let ⟨z⟩ := hι in ⟨z, λ _, false.elim⟩) $
λ i s ⟨j, H⟩, let ⟨k, h₁, h₂⟩ := D i j in
⟨k, λ a h, or.cases_on (multiset.mem_cons.1 h)
(λ h, h.symm ▸ h₁)
(λ h, trans (H _ h) h₂)⟩
theorem finset.exists_le {α : Type u} [nonempty α] [directed_order α] (s : finset α) :
∃ M, ∀ i ∈ s, i ≤ M :=
directed.finset_le directed_order.directed s
|
lemma of_real_0 [simp]: "of_real 0 = 0" |
import PnP2023.Lec_01_25.Answer
namespace Waffle
theorem Answer.eq_of_le_le (a b : Answer) :
a ≤ b → b ≤ a → a = b := by sorry |
example : ∀ a b c : ℕ, a = b → a = c → c = b :=
begin
intros,
transitivity,
symmetry,
assumption,
assumption
end
|
lemma reflect_poly_0 [simp]: "reflect_poly 0 = 0" |
lemma frontier_empty [simp]: "frontier {} = {}" |
/-
Copyright (c) 2015 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis, Jeremy Avigad
The square root function.
-/
import .ivt
open analysis real classical topology
noncomputable theory
private definition sqr_lb (x : ℝ) : ℝ := 0
private theorem sqr_lb_is_lb (x : ℝ) (H : x ≥ 0) : (sqr_lb x) * (sqr_lb x) ≤ x :=
by rewrite [↑sqr_lb, zero_mul]; assumption
private definition sqr_ub (x : ℝ) : ℝ := x + 1
private theorem sqr_ub_is_ub (x : ℝ) (H : x ≥ 0) : (sqr_ub x) * (sqr_ub x) ≥ x :=
begin
rewrite [↑sqr_ub, left_distrib, mul_one, right_distrib, one_mul, {x + 1}add.comm, -*add.assoc],
apply le_add_of_nonneg_left,
repeat apply add_nonneg,
apply mul_nonneg,
repeat assumption,
apply zero_le_one
end
private theorem lb_le_ub (x : ℝ) (H : x ≥ 0) : sqr_lb x ≤ sqr_ub x :=
begin
rewrite [↑sqr_lb, ↑sqr_ub],
apply add_nonneg,
assumption,
apply zero_le_one
end
private lemma sqr_cts : continuous (λ x : ℝ, x * x) := continuous_mul_of_continuous continuous_id continuous_id
definition sqrt (x : ℝ) : ℝ :=
if H : x ≥ 0 then
some (intermediate_value_incr_weak sqr_cts (lb_le_ub x H) (sqr_lb_is_lb x H) (sqr_ub_is_ub x H))
else 0
private theorem sqrt_spec {x : ℝ} (H : x ≥ 0) : sqrt x * sqrt x = x ∧ sqrt x ≥ 0 :=
begin
rewrite [↑sqrt, dif_pos H],
note Hs := some_spec (intermediate_value_incr_weak sqr_cts (lb_le_ub x H)
(sqr_lb_is_lb x H) (sqr_ub_is_ub x H)),
cases Hs with Hs1 Hs2,
cases Hs2 with Hs2a Hs2b,
exact and.intro Hs2b Hs1
end
theorem sqrt_mul_self {x : ℝ} (H : x ≥ 0) : sqrt x * sqrt x = x := and.left (sqrt_spec H)
theorem sqrt_nonneg (x : ℝ) : sqrt x ≥ 0 :=
if H : x ≥ 0 then and.right (sqrt_spec H) else by rewrite [↑sqrt, dif_neg H]; exact le.refl 0
theorem sqrt_squared {x : ℝ} (H : x ≥ 0) : (sqrt x)^2 = x :=
by krewrite [pow_two, sqrt_mul_self H]
theorem sqrt_zero : sqrt (0 : ℝ) = 0 :=
have sqrt 0 * sqrt 0 = 0, from sqrt_mul_self !le.refl,
or.elim (eq_zero_or_eq_zero_of_mul_eq_zero this) (λ H, H) (λ H, H)
theorem sqrt_squared_of_nonneg {x : ℝ} (H : x ≥ 0) : sqrt (x^2) = x :=
have sqrt (x^2)^2 = x^2, from sqrt_squared (squared_nonneg x),
eq_of_squared_eq_squared_of_nonneg (sqrt_nonneg (x^2)) H this
theorem sqrt_squared' (x : ℝ) : sqrt (x^2) = abs x :=
have x^2 = (abs x)^2, by krewrite [+pow_two, -abs_mul, abs_mul_self],
using this, by rewrite [this, sqrt_squared_of_nonneg (abs_nonneg x)]
theorem sqrt_mul {x y : ℝ} (Hx : x ≥ 0) (Hy : y ≥ 0) : sqrt (x * y) = sqrt x * sqrt y :=
have (sqrt (x * y))^2 = (sqrt x * sqrt y)^2, from calc
(sqrt (x * y))^2 = x * y : by rewrite [sqrt_squared (mul_nonneg Hx Hy)]
... = (sqrt x)^2 * (sqrt y)^2 : by rewrite [sqrt_squared Hx, sqrt_squared Hy]
... = (sqrt x * sqrt y)^2 : by krewrite [*pow_two]; rewrite [*mul.assoc,
mul.left_comm (sqrt y)],
eq_of_squared_eq_squared_of_nonneg !sqrt_nonneg (mul_nonneg !sqrt_nonneg !sqrt_nonneg) this
|
def g (x : Nat) (b : Bool) :=
if b then
x - 1
else
x + 1
theorem g_eq (x : Nat) (h : ¬ x = 0) : g x (x > 0) = x - 1 ∧ g x false = x + 1 := by
have : x > 0 := by match x with
| 0 => contradiction
| x+1 => apply Nat.zero_lt_succ
simp [g, this]
macro_rules
| `(tactic| decreasing_tactic) =>
`(tactic|
(simp [invImage, InvImage, Prod.lex, sizeOfWFRel, measure, Nat.lt_wfRel, WellFoundedRelation.rel, g_eq, *]
apply Nat.pred_lt; assumption))
def f (x : Nat) : Nat :=
if h : x = 0 then
1
else
f (g x (x > 0)) + 2
termination_by f x => x
|
/-
lemma divides_p_times (r : ℕ) (n : ℕ) : p^r ∣ n ↔ p^(r+1) ∣ (p * n) :=
calc p^r ∣ n ↔ (p * p^r) ∣ (p * n) : (nat.mul_dvd_mul_iff_left (gt_zero hp)).symm
... = (p^r * p ∣ p * n) : by rw mul_comm
lemma exactly_divides_p_times (r : ℕ) (n : ℕ) : p^r ∣∣ n ↔ p^(r+1) ∣∣ (p * n) :=
have eq : (p * n) / p^(r+1) = n / p^r, from
calc (p * n) / p^(r+1) = (p * n) / (p^r * p) : rfl
... = (p * n) / (p * p^r) : by rw mul_comm (p^r) p
... = (p * n) / p / p^r : by rw nat.div_div_eq_div_mul
... = n / p^r : by rw (nat.mul_div_cancel_left n (gt_zero hp)),
-- : congr_arg (λ m, m / p^r) (nat.mul_div_cancel_left n gt_zero),
and_congr (divides_p_times hp r n) (by rw eq)
lemma exactly_divides' {r : ℕ} {n : ℕ} : p^r ∣∣ n → (∀ i, p^i ∣ n ↔ i ≤ r) :=
begin
intros prn i, apply iff.intro,
{ intro pin,
apply (le_or_gt _ _).resolve_right, intro i_gt_r,
have :=
calc p^r * p = p^(r+1) : rfl
... ∣ p^i : pow_dvd_pow p i_gt_r
... ∣ n : pin,
exact absurd (dvd_div_of_mul_dvd (pos_pow_of_pos r (gt_zero hp)) this) prn.right,
},
{ intro i_le_r,
exact dvd.trans (pow_dvd_pow p i_le_r) (and.left prn) }
end
-/
/-
lemma exactly_divides_mul (r s a b : ℕ) : p^r ∣∣ a → p^s ∣∣ b → p^(r+s) ∣∣ a*b :=
begin
intros pra psb, split,
{ rw nat.pow_add, exact mul_dvd_mul pra.left psb.left },
let a' := a / p^r,
have ha : p^r * a' = a := nat.mul_div_cancel' pra.left,
let b' := b / p^s,
have hb : p^s * b' = b := nat.mul_div_cancel' psb.left,
have : (a * b) / (p^(r+s)) = (a / p^r) * (b / p^s) :=
calc (a * b) / (p^(r+s)) = ((p^r * a') * (p^s * b')) / (p^r * p^s)
: by rw [ha, hb, pow_add]
... = ((p^r * p^s) * (a' * b')) / (p^r * p^s)
: by ac_refl
... = a' * b'
: by rw nat.mul_div_cancel_left _
(mul_pos (pos_pow_of_pos r (gt_zero hp)) (pos_pow_of_pos s (gt_zero hp)))
... = (a / p^r) * (b / p^s) : rfl,
rw this,
exact prime.not_dvd_mul hp pra.right psb.right
end
-/
|
section
variables (x y z : ℕ)
variables (h₁ : x = y) (h₂ : y = z)
include h₁ h₂
theorem foo : x = z :=
begin
rw [h₁, h₂]
end
omit h₁ h₂
theorem bar : x = z :=
eq.trans h₁ h₂
theorem baz : x = x := rfl
#check @foo
#check @bar
#check baz
end
|
/-
Copyright (c) Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Yourong Zang
! This file was ported from Lean 3 source module analysis.complex.real_deriv
! leanprover-community/mathlib commit e9be2fa75faa22892937c275e27a91cd558cf8c0
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Analysis.Calculus.ContDiff
import Mathbin.Analysis.Complex.Conformal
import Mathbin.Analysis.Calculus.Conformal.NormedSpace
/-! # Real differentiability of complex-differentiable functions
`has_deriv_at.real_of_complex` expresses that, if a function on `ℂ` is differentiable (over `ℂ`),
then its restriction to `ℝ` is differentiable over `ℝ`, with derivative the real part of the
complex derivative.
`differentiable_at.conformal_at` states that a real-differentiable function with a nonvanishing
differential from the complex plane into an arbitrary complex-normed space is conformal at a point
if it's holomorphic at that point. This is a version of Cauchy-Riemann equations.
`conformal_at_iff_differentiable_at_or_differentiable_at_comp_conj` proves that a real-differential
function with a nonvanishing differential between the complex plane is conformal at a point if and
only if it's holomorphic or antiholomorphic at that point.
## TODO
* The classical form of Cauchy-Riemann equations
* On a connected open set `u`, a function which is `conformal_at` each point is either holomorphic
throughout or antiholomorphic throughout.
## Warning
We do NOT require conformal functions to be orientation-preserving in this file.
-/
section RealDerivOfComplex
/-! ### Differentiability of the restriction to `ℝ` of complex functions -/
open Complex
variable {e : ℂ → ℂ} {e' : ℂ} {z : ℝ}
/-- If a complex function is differentiable at a real point, then the induced real function is also
differentiable at this point, with a derivative equal to the real part of the complex derivative. -/
theorem HasStrictDerivAt.real_of_complex (h : HasStrictDerivAt e e' z) :
HasStrictDerivAt (fun x : ℝ => (e x).re) e'.re z :=
by
have A : HasStrictFderivAt (coe : ℝ → ℂ) of_real_clm z := of_real_clm.has_strict_fderiv_at
have B :
HasStrictFderivAt e ((ContinuousLinearMap.smulRight 1 e' : ℂ →L[ℂ] ℂ).restrictScalars ℝ)
(of_real_clm z) :=
h.has_strict_fderiv_at.restrict_scalars ℝ
have C : HasStrictFderivAt re re_clm (e (of_real_clm z)) := re_clm.has_strict_fderiv_at
simpa using (C.comp z (B.comp z A)).HasStrictDerivAt
#align has_strict_deriv_at.real_of_complex HasStrictDerivAt.real_of_complex
/-- If a complex function `e` is differentiable at a real point, then the function `ℝ → ℝ` given by
the real part of `e` is also differentiable at this point, with a derivative equal to the real part
of the complex derivative. -/
theorem HasDerivAt.real_of_complex (h : HasDerivAt e e' z) :
HasDerivAt (fun x : ℝ => (e x).re) e'.re z :=
by
have A : HasFderivAt (coe : ℝ → ℂ) of_real_clm z := of_real_clm.has_fderiv_at
have B :
HasFderivAt e ((ContinuousLinearMap.smulRight 1 e' : ℂ →L[ℂ] ℂ).restrictScalars ℝ)
(of_real_clm z) :=
h.has_fderiv_at.restrict_scalars ℝ
have C : HasFderivAt re re_clm (e (of_real_clm z)) := re_clm.has_fderiv_at
simpa using (C.comp z (B.comp z A)).HasDerivAt
#align has_deriv_at.real_of_complex HasDerivAt.real_of_complex
theorem ContDiffAt.real_of_complex {n : ℕ∞} (h : ContDiffAt ℂ n e z) :
ContDiffAt ℝ n (fun x : ℝ => (e x).re) z :=
by
have A : ContDiffAt ℝ n (coe : ℝ → ℂ) z := of_real_clm.cont_diff.cont_diff_at
have B : ContDiffAt ℝ n e z := h.restrict_scalars ℝ
have C : ContDiffAt ℝ n re (e z) := re_clm.cont_diff.cont_diff_at
exact C.comp z (B.comp z A)
#align cont_diff_at.real_of_complex ContDiffAt.real_of_complex
theorem ContDiff.real_of_complex {n : ℕ∞} (h : ContDiff ℂ n e) :
ContDiff ℝ n fun x : ℝ => (e x).re :=
contDiff_iff_contDiffAt.2 fun x => h.ContDiffAt.real_of_complex
#align cont_diff.real_of_complex ContDiff.real_of_complex
variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℂ E]
theorem HasStrictDerivAt.complexToReal_fderiv' {f : ℂ → E} {x : ℂ} {f' : E}
(h : HasStrictDerivAt f f' x) :
HasStrictFderivAt f (reClm.smul_right f' + I • imClm.smul_right f') x := by
simpa only [Complex.restrictScalars_one_smul_right'] using
h.has_strict_fderiv_at.restrict_scalars ℝ
#align has_strict_deriv_at.complex_to_real_fderiv' HasStrictDerivAt.complexToReal_fderiv'
theorem HasDerivAt.complexToReal_fderiv' {f : ℂ → E} {x : ℂ} {f' : E} (h : HasDerivAt f f' x) :
HasFderivAt f (reClm.smul_right f' + I • imClm.smul_right f') x := by
simpa only [Complex.restrictScalars_one_smul_right'] using h.has_fderiv_at.restrict_scalars ℝ
#align has_deriv_at.complex_to_real_fderiv' HasDerivAt.complexToReal_fderiv'
theorem HasDerivWithinAt.complexToReal_fderiv' {f : ℂ → E} {s : Set ℂ} {x : ℂ} {f' : E}
(h : HasDerivWithinAt f f' s x) :
HasFderivWithinAt f (reClm.smul_right f' + I • imClm.smul_right f') s x := by
simpa only [Complex.restrictScalars_one_smul_right'] using
h.has_fderiv_within_at.restrict_scalars ℝ
#align has_deriv_within_at.complex_to_real_fderiv' HasDerivWithinAt.complexToReal_fderiv'
theorem HasStrictDerivAt.complexToReal_fderiv {f : ℂ → ℂ} {f' x : ℂ} (h : HasStrictDerivAt f f' x) :
HasStrictFderivAt f (f' • (1 : ℂ →L[ℝ] ℂ)) x := by
simpa only [Complex.restrictScalars_one_smulRight] using h.has_strict_fderiv_at.restrict_scalars ℝ
#align has_strict_deriv_at.complex_to_real_fderiv HasStrictDerivAt.complexToReal_fderiv
theorem HasDerivAt.complexToReal_fderiv {f : ℂ → ℂ} {f' x : ℂ} (h : HasDerivAt f f' x) :
HasFderivAt f (f' • (1 : ℂ →L[ℝ] ℂ)) x := by
simpa only [Complex.restrictScalars_one_smulRight] using h.has_fderiv_at.restrict_scalars ℝ
#align has_deriv_at.complex_to_real_fderiv HasDerivAt.complexToReal_fderiv
theorem HasDerivWithinAt.complexToReal_fderiv {f : ℂ → ℂ} {s : Set ℂ} {f' x : ℂ}
(h : HasDerivWithinAt f f' s x) : HasFderivWithinAt f (f' • (1 : ℂ →L[ℝ] ℂ)) s x := by
simpa only [Complex.restrictScalars_one_smulRight] using h.has_fderiv_within_at.restrict_scalars ℝ
#align has_deriv_within_at.complex_to_real_fderiv HasDerivWithinAt.complexToReal_fderiv
/-- If a complex function `e` is differentiable at a real point, then its restriction to `ℝ` is
differentiable there as a function `ℝ → ℂ`, with the same derivative. -/
theorem HasDerivAt.comp_of_real (hf : HasDerivAt e e' ↑z) : HasDerivAt (fun y : ℝ => e ↑y) e' z :=
by simpa only [of_real_clm_apply, of_real_one, mul_one] using hf.comp z of_real_clm.has_deriv_at
#align has_deriv_at.comp_of_real HasDerivAt.comp_of_real
/-- If a function `f : ℝ → ℝ` is differentiable at a (real) point `x`, then it is also
differentiable as a function `ℝ → ℂ`. -/
theorem HasDerivAt.of_real_comp {f : ℝ → ℝ} {u : ℝ} (hf : HasDerivAt f u z) :
HasDerivAt (fun y : ℝ => ↑(f y) : ℝ → ℂ) u z := by
simpa only [of_real_clm_apply, of_real_one, real_smul, mul_one] using
of_real_clm.has_deriv_at.scomp z hf
#align has_deriv_at.of_real_comp HasDerivAt.of_real_comp
end RealDerivOfComplex
section Conformality
/-! ### Conformality of real-differentiable complex maps -/
open Complex ContinuousLinearMap
open ComplexConjugate
variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℂ E] {z : ℂ} {f : ℂ → E}
/-- A real differentiable function of the complex plane into some complex normed space `E` is
conformal at a point `z` if it is holomorphic at that point with a nonvanishing differential.
This is a version of the Cauchy-Riemann equations. -/
theorem DifferentiableAt.conformalAt (h : DifferentiableAt ℂ f z) (hf' : deriv f z ≠ 0) :
ConformalAt f z :=
by
rw [conformalAt_iff_isConformalMap_fderiv, (h.has_fderiv_at.restrict_scalars ℝ).fderiv]
apply isConformalMap_complex_linear
simpa only [Ne.def, ext_ring_iff]
#align differentiable_at.conformal_at DifferentiableAt.conformalAt
/-- A complex function is conformal if and only if the function is holomorphic or antiholomorphic
with a nonvanishing differential. -/
theorem conformalAt_iff_differentiableAt_or_differentiableAt_comp_conj {f : ℂ → ℂ} {z : ℂ} :
ConformalAt f z ↔
(DifferentiableAt ℂ f z ∨ DifferentiableAt ℂ (f ∘ conj) (conj z)) ∧ fderiv ℝ f z ≠ 0 :=
by
rw [conformalAt_iff_isConformalMap_fderiv]
rw [isConformalMap_iff_is_complex_or_conj_linear]
apply and_congr_left
intro h
have h_diff := h.imp_symm fderiv_zero_of_not_differentiableAt
apply or_congr
· rw [differentiableAt_iff_restrictScalars ℝ h_diff]
rw [← conj_conj z] at h_diff
rw [differentiableAt_iff_restrictScalars ℝ (h_diff.comp _ conj_cle.differentiable_at)]
refine' exists_congr fun g => rfl.congr _
have : fderiv ℝ conj (conj z) = _ := conj_cle.fderiv
simp [fderiv.comp _ h_diff conj_cle.differentiable_at, this, conj_conj]
#align conformal_at_iff_differentiable_at_or_differentiable_at_comp_conj conformalAt_iff_differentiableAt_or_differentiableAt_comp_conj
end Conformality
|
/-
Copyright (c) 2020 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Eric Wieser
-/
import algebra.char_p.basic
import algebra.ring_quot
/-!
# Characteristic of quotients rings
-/
universes u v
namespace char_p
theorem quotient (R : Type u) [comm_ring R] (p : ℕ) [hp1 : fact p.prime] (hp2 : ↑p ∈ nonunits R) :
char_p (ideal.span {p} : ideal R).quotient p :=
have hp0 : (p : (ideal.span {p} : ideal R).quotient) = 0,
from (ideal.quotient.mk (ideal.span {p} : ideal R)).map_nat_cast p ▸
ideal.quotient.eq_zero_iff_mem.2 (ideal.subset_span $ set.mem_singleton _),
ring_char.of_eq $ or.resolve_left ((nat.dvd_prime hp1.1).1 $ ring_char.dvd hp0) $ λ h1,
hp2 $ is_unit_iff_dvd_one.2 $ ideal.mem_span_singleton.1 $ ideal.quotient.eq_zero_iff_mem.1 $
@@subsingleton.elim (@@char_p.subsingleton _ $ ring_char.of_eq h1) _ _
/-- If an ideal does not contain any coercions of natural numbers other than zero, then its quotient
inherits the characteristic of the underlying ring. -/
lemma quotient' {R : Type*} [comm_ring R] (p : ℕ) [char_p R p] (I : ideal R)
(h : ∀ x : ℕ, (x : R) ∈ I → (x : R) = 0) :
char_p I.quotient p :=
⟨λ x, begin
rw [←cast_eq_zero_iff R p x, ←(ideal.quotient.mk I).map_nat_cast],
refine quotient.eq'.trans (_ : ↑x - 0 ∈ I ↔ _),
rw sub_zero,
exact ⟨h x, λ h', h'.symm ▸ I.zero_mem⟩,
end⟩
end char_p
|
State Before: α : Type u
m : OuterMeasure α
s✝ s₁ s₂ : Set α
s : ℕ → Set α
h : ∀ (i : ℕ), IsCaratheodory m (s i)
hd : Pairwise (Disjoint on s)
t : Set α
⊢ ∑ i in Finset.range 0, ↑m (t ∩ s i) = ↑m (t ∩ ⋃ (i : ℕ) (_ : i < 0), s i) State After: no goals Tactic: simp [Nat.not_lt_zero, m.empty] State Before: α : Type u
m : OuterMeasure α
s✝ s₁ s₂ : Set α
s : ℕ → Set α
h : ∀ (i : ℕ), IsCaratheodory m (s i)
hd : Pairwise (Disjoint on s)
t : Set α
n : ℕ
⊢ ∑ i in Finset.range (Nat.succ n), ↑m (t ∩ s i) = ↑m (t ∩ ⋃ (i : ℕ) (_ : i < Nat.succ n), s i) State After: α : Type u
m : OuterMeasure α
s✝ s₁ s₂ : Set α
s : ℕ → Set α
h : ∀ (i : ℕ), IsCaratheodory m (s i)
hd : Pairwise (Disjoint on s)
t : Set α
n : ℕ
⊢ (s n ∩ ⋃ (k : ℕ) (_ : k < n), s k) ⊆ ∅ Tactic: rw [biUnion_lt_succ, Finset.sum_range_succ, Set.union_comm, isCaratheodory_sum h hd,
m.measure_inter_union _ (h n), add_comm] State Before: α : Type u
m : OuterMeasure α
s✝ s₁ s₂ : Set α
s : ℕ → Set α
h : ∀ (i : ℕ), IsCaratheodory m (s i)
hd : Pairwise (Disjoint on s)
t : Set α
n : ℕ
⊢ (s n ∩ ⋃ (k : ℕ) (_ : k < n), s k) ⊆ ∅ State After: α : Type u
m : OuterMeasure α
s✝ s₁ s₂ : Set α
s : ℕ → Set α
h : ∀ (i : ℕ), IsCaratheodory m (s i)
hd : Pairwise (Disjoint on s)
t : Set α
n : ℕ
a : α
⊢ (a ∈ s n ∩ ⋃ (k : ℕ) (_ : k < n), s k) → a ∈ ∅ Tactic: intro a State Before: α : Type u
m : OuterMeasure α
s✝ s₁ s₂ : Set α
s : ℕ → Set α
h : ∀ (i : ℕ), IsCaratheodory m (s i)
hd : Pairwise (Disjoint on s)
t : Set α
n : ℕ
a : α
⊢ (a ∈ s n ∩ ⋃ (k : ℕ) (_ : k < n), s k) → a ∈ ∅ State After: no goals Tactic: simpa using fun (h₁ : a ∈ s n) i (hi : i < n) h₂ => (hd (ne_of_gt hi)).le_bot ⟨h₁, h₂⟩ |
From iris.proofmode Require Import tactics.
From aneris.aneris_lang Require Import network adequacy.
From aneris.aneris_lang.program_logic Require Export aneris_weakestpre.
Definition aneris_adequate (e :expr) (ip : ip_address) (σ : state)
(φ : val → Prop) :=
adequate NotStuck (mkExpr ip e) σ (λ v _, ∃ w, v = mkVal ip w ∧ φ w).
Theorem adequacy `{anerisPreG Σ Mdl} IPs A B
lbls obs_send_sas obs_rec_sas e ip σ φ :
aneris_model_rel_finitary Mdl →
(∀ `{anerisG Mdl Σ}, ⊢ |={⊤}=> ∃ (f : socket_address → socket_interp Σ),
fixed A -∗
([∗ set] a ∈ A, a ⤇ (f a)) -∗
([∗ set] b ∈ B, b ⤳[bool_decide (b ∈ obs_send_sas), bool_decide (b ∈ obs_rec_sas)] (∅, ∅)) -∗
frag_st Mdl.(model_state_initial) -∗
([∗ set] i ∈ IPs, free_ip i) -∗
([∗ set] lbl ∈ lbls, alloc_evs lbl []) -∗
([∗ set] sa ∈ obs_send_sas, sendon_evs sa []) -∗
([∗ set] sa ∈ obs_rec_sas, receiveon_evs sa []) -∗
observed_send obs_send_sas -∗
observed_receive obs_rec_sas -∗
WP e @[ip] ⊤ {{ v, ⌜φ v⌝ }}) →
ip ∉ IPs →
dom (gset ip_address) (state_ports_in_use σ) = IPs →
(∀ ip, ip ∈ IPs → state_ports_in_use σ !! ip = Some ∅) →
(∀ a, a ∈ A → ip_of_address a ∈ IPs) →
state_heaps σ = {[ip:=∅]} →
state_sockets σ = {[ip:=∅]} →
state_ms σ = ∅ →
aneris_adequate e ip σ φ.
Proof.
intros HMdlfin Hwp Hipdom Hpiiu Hip Hfixdom Hste Hsce Hmse.
eapply adequacy; [done| |done|done|done|done|done|done|done].
intros dg.
iMod (Hwp dg) as (f) "Hwp".
iModIntro. iExists _. iIntros "??????????? /=".
rewrite !aneris_wp_unfold /aneris_wp_def.
iSpecialize ("Hwp" with "[$] [$] [$] [$] [$] [$] [$] [$] [$] [$] [$]").
iApply (wp_wand with "Hwp").
eauto.
Qed.
Theorem adequacy_hoare `{anerisPreG Σ Mdl} IPs A B
lbls obs_send_sas obs_rec_sas e σ φ ip :
aneris_model_rel_finitary Mdl →
(∀ `{anerisG Mdl Σ}, ⊢ ∃ (f : socket_address → socket_interp Σ),
{{{ fixed A ∗
([∗ set] a ∈ A, a ⤇ (f a)) ∗
([∗ set] b ∈ B, b ⤳[bool_decide (b ∈ obs_send_sas), bool_decide (b ∈ obs_rec_sas)] (∅, ∅)) ∗
frag_st Mdl.(model_state_initial) ∗
([∗ set] ip ∈ IPs, free_ip ip) ∗
([∗ set] lbl ∈ lbls, alloc_evs lbl []) ∗
([∗ set] sa ∈ obs_send_sas, sendon_evs sa []) ∗
([∗ set] sa ∈ obs_rec_sas, receiveon_evs sa []) ∗
observed_send obs_send_sas ∗
observed_receive obs_rec_sas }}}
e @[ip]
{{{ v, RET v; ⌜φ v⌝ }}}) →
ip ∉ IPs →
dom (gset ip_address) (state_ports_in_use σ) = IPs →
(∀ i, i ∈ IPs → state_ports_in_use σ !! i = Some ∅) →
(∀ a, a ∈ A → ip_of_address a ∈ IPs) →
state_heaps σ = {[ip:=∅]} →
state_sockets σ = {[ip:=∅]} →
state_ms σ = ∅ →
aneris_adequate e ip σ φ.
Proof.
intros ? Hwp ???????.
eapply adequacy; eauto.
intros ?. iModIntro.
iDestruct Hwp as (f) "#Hwp".
iExists f. iIntros "??????????".
iApply ("Hwp" with "[$]"); auto.
Qed.
|
Class inhabited(A: Type): Type := mk_inhabited { default: A }.
Global Arguments mk_inhabited {_} _.
Global Hint Mode inhabited + : typeclass_instances.
Global Hint Extern 1 (inhabited _) =>
simple refine (mk_inhabited _); constructor
: typeclass_instances.
Module InhabitedTests.
Goal inhabited nat. typeclasses eauto. Abort.
Goal inhabited (list nat). typeclasses eauto. Abort.
Goal forall A, inhabited (option A). typeclasses eauto. Abort.
Inductive test_foo: Type :=
| C1(x: False)
| C2
| C3(x: False).
Goal inhabited test_foo. typeclasses eauto. Abort.
End InhabitedTests.
(* TODO move code below to specific files *)
Require Import coqutil.Word.Interface.
Global Instance word_inhabited{width: BinInt.Z}{word: word.word width}: inhabited word :=
mk_inhabited (word.of_Z BinInt.Z0).
Require Import coqutil.Map.Interface.
Global Instance map_inhabited{key value: Type}{map: map.map key value}: inhabited map :=
mk_inhabited map.empty.
Module Option.
Definition force{A: Type}{i: inhabited A}(o: option A): A :=
match o with
| Some a => a
| None => default
end.
End Option.
|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Yury Kudryashov
-/
import data.real.sqrt
import tactic.interval_cases
import ring_theory.algebraic
import data.rat.sqrt
import ring_theory.int.basic
/-!
# Irrational real numbers
In this file we define a predicate `irrational` on `ℝ`, prove that the `n`-th root of an integer
number is irrational if it is not integer, and that `sqrt q` is irrational if and only if
`rat.sqrt q * rat.sqrt q ≠ q ∧ 0 ≤ q`.
We also provide dot-style constructors like `irrational.add_rat`, `irrational.rat_sub` etc.
-/
open rat real multiplicity
/-- A real number is irrational if it is not equal to any rational number. -/
def irrational (x : ℝ) := x ∉ set.range (coe : ℚ → ℝ)
lemma irrational_iff_ne_rational (x : ℝ) : irrational x ↔ ∀ a b : ℤ, x ≠ a / b :=
by simp only [irrational, rat.forall, cast_mk, not_exists, set.mem_range, cast_coe_int, cast_div,
eq_comm]
/-- A transcendental real number is irrational. -/
lemma transcendental.irrational {r : ℝ} (tr : transcendental ℚ r) :
irrational r :=
by { rintro ⟨a, rfl⟩, exact tr (is_algebraic_algebra_map a) }
/-!
### Irrationality of roots of integer and rational numbers
-/
/-- If `x^n`, `n > 0`, is integer and is not the `n`-th power of an integer, then
`x` is irrational. -/
theorem irrational_nrt_of_notint_nrt {x : ℝ} (n : ℕ) (m : ℤ)
(hxr : x ^ n = m) (hv : ¬ ∃ y : ℤ, x = y) (hnpos : 0 < n) :
irrational x :=
begin
rintros ⟨⟨N, D, P, C⟩, rfl⟩,
rw [← cast_pow] at hxr,
have c1 : ((D : ℤ) : ℝ) ≠ 0,
{ rw [int.cast_ne_zero, int.coe_nat_ne_zero], exact ne_of_gt P },
have c2 : ((D : ℤ) : ℝ) ^ n ≠ 0 := pow_ne_zero _ c1,
rw [num_denom', cast_pow, cast_mk, div_pow, div_eq_iff_mul_eq c2,
← int.cast_pow, ← int.cast_pow, ← int.cast_mul, int.cast_inj] at hxr,
have hdivn : ↑D ^ n ∣ N ^ n := dvd.intro_left m hxr,
rw [← int.dvd_nat_abs, ← int.coe_nat_pow, int.coe_nat_dvd, int.nat_abs_pow,
nat.pow_dvd_pow_iff hnpos] at hdivn,
obtain rfl : D = 1 := by rw [← nat.gcd_eq_right hdivn, C.gcd_eq_one],
refine hv ⟨N, _⟩,
rw [num_denom', int.coe_nat_one, mk_eq_div, int.cast_one, div_one, cast_coe_int]
end
/-- If `x^n = m` is an integer and `n` does not divide the `multiplicity p m`, then `x`
is irrational. -/
theorem irrational_nrt_of_n_not_dvd_multiplicity {x : ℝ} (n : ℕ) {m : ℤ} (hm : m ≠ 0) (p : ℕ)
[hp : fact p.prime] (hxr : x ^ n = m)
(hv : (multiplicity (p : ℤ) m).get (finite_int_iff.2 ⟨hp.1.ne_one, hm⟩) % n ≠ 0) :
irrational x :=
begin
rcases nat.eq_zero_or_pos n with rfl | hnpos,
{ rw [eq_comm, pow_zero, ← int.cast_one, int.cast_inj] at hxr,
simpa [hxr, multiplicity.one_right (mt is_unit_iff_dvd_one.1
(mt int.coe_nat_dvd.1 hp.1.not_dvd_one)), nat.zero_mod] using hv },
refine irrational_nrt_of_notint_nrt _ _ hxr _ hnpos,
rintro ⟨y, rfl⟩,
rw [← int.cast_pow, int.cast_inj] at hxr, subst m,
have : y ≠ 0, { rintro rfl, rw zero_pow hnpos at hm, exact hm rfl },
erw [multiplicity.pow' (nat.prime_iff_prime_int.1 hp.1)
(finite_int_iff.2 ⟨hp.1.ne_one, this⟩), nat.mul_mod_right] at hv,
exact hv rfl
end
theorem irrational_sqrt_of_multiplicity_odd (m : ℤ) (hm : 0 < m)
(p : ℕ) [hp : fact p.prime]
(Hpv : (multiplicity (p : ℤ) m).get
(finite_int_iff.2 ⟨hp.1.ne_one, (ne_of_lt hm).symm⟩) % 2 = 1) :
irrational (sqrt m) :=
@irrational_nrt_of_n_not_dvd_multiplicity _ 2 _ (ne.symm (ne_of_lt hm)) p hp
(sq_sqrt (int.cast_nonneg.2 $ le_of_lt hm))
(by rw Hpv; exact one_ne_zero)
theorem nat.prime.irrational_sqrt {p : ℕ} (hp : nat.prime p) : irrational (sqrt p) :=
@irrational_sqrt_of_multiplicity_odd p (int.coe_nat_pos.2 hp.pos) p ⟨hp⟩ $
by simp [multiplicity_self (mt is_unit_iff_dvd_one.1 (mt int.coe_nat_dvd.1 hp.not_dvd_one) : _)];
refl
/-- **Irrationality of the Square Root of 2** -/
theorem irrational_sqrt_two : irrational (sqrt 2) :=
by simpa using nat.prime_two.irrational_sqrt
theorem irrational_sqrt_rat_iff (q : ℚ) : irrational (sqrt q) ↔
rat.sqrt q * rat.sqrt q ≠ q ∧ 0 ≤ q :=
if H1 : rat.sqrt q * rat.sqrt q = q
then iff_of_false (not_not_intro ⟨rat.sqrt q,
by rw [← H1, cast_mul, sqrt_mul_self (cast_nonneg.2 $ rat.sqrt_nonneg q),
sqrt_eq, abs_of_nonneg (rat.sqrt_nonneg q)]⟩) (λ h, h.1 H1)
else if H2 : 0 ≤ q
then iff_of_true (λ ⟨r, hr⟩, H1 $ (exists_mul_self _).1 ⟨r,
by rwa [eq_comm, sqrt_eq_iff_mul_self_eq (cast_nonneg.2 H2), ← cast_mul, rat.cast_inj] at hr;
rw [← hr]; exact real.sqrt_nonneg _⟩) ⟨H1, H2⟩
else iff_of_false (not_not_intro ⟨0,
by rw cast_zero; exact (sqrt_eq_zero_of_nonpos (rat.cast_nonpos.2 $ le_of_not_le H2)).symm⟩)
(λ h, H2 h.2)
instance (q : ℚ) : decidable (irrational (sqrt q)) :=
decidable_of_iff' _ (irrational_sqrt_rat_iff q)
/-!
### Dot-style operations on `irrational`
#### Coercion of a rational/integer/natural number is not irrational
-/
namespace irrational
variable {x : ℝ}
/-!
#### Irrational number is not equal to a rational/integer/natural number
-/
theorem ne_rat (h : irrational x) (q : ℚ) : x ≠ q := λ hq, h ⟨q, hq.symm⟩
theorem ne_int (h : irrational x) (m : ℤ) : x ≠ m :=
by { rw ← rat.cast_coe_int, exact h.ne_rat _ }
theorem ne_nat (h : irrational x) (m : ℕ) : x ≠ m := h.ne_int m
theorem ne_zero (h : irrational x) : x ≠ 0 := by exact_mod_cast h.ne_nat 0
theorem ne_one (h : irrational x) : x ≠ 1 := by simpa only [nat.cast_one] using h.ne_nat 1
end irrational
@[simp] lemma rat.not_irrational (q : ℚ) : ¬irrational q := λ h, h ⟨q, rfl⟩
@[simp] lemma int.not_irrational (m : ℤ) : ¬irrational m := λ h, h.ne_int m rfl
@[simp] lemma nat.not_irrational (m : ℕ) : ¬irrational m := λ h, h.ne_nat m rfl
namespace irrational
variables (q : ℚ) {x y : ℝ}
/-!
#### Addition of rational/integer/natural numbers
-/
/-- If `x + y` is irrational, then at least one of `x` and `y` is irrational. -/
theorem add_cases : irrational (x + y) → irrational x ∨ irrational y :=
begin
delta irrational,
contrapose!,
rintros ⟨⟨rx, rfl⟩, ⟨ry, rfl⟩⟩,
exact ⟨rx + ry, cast_add rx ry⟩
end
theorem of_rat_add (h : irrational (q + x)) : irrational x :=
h.add_cases.resolve_left q.not_irrational
theorem rat_add (h : irrational x) : irrational (q + x) :=
of_rat_add (-q) $ by rwa [cast_neg, neg_add_cancel_left]
theorem of_add_rat : irrational (x + q) → irrational x :=
add_comm ↑q x ▸ of_rat_add q
theorem add_rat (h : irrational x) : irrational (x + q) :=
add_comm ↑q x ▸ h.rat_add q
theorem of_int_add (m : ℤ) (h : irrational (m + x)) : irrational x :=
by { rw ← cast_coe_int at h, exact h.of_rat_add m }
theorem of_add_int (m : ℤ) (h : irrational (x + m)) : irrational x :=
of_int_add m $ add_comm x m ▸ h
theorem int_add (h : irrational x) (m : ℤ) : irrational (m + x) :=
by { rw ← cast_coe_int, exact h.rat_add m }
theorem add_int (h : irrational x) (m : ℤ) : irrational (x + m) :=
add_comm ↑m x ▸ h.int_add m
theorem of_nat_add (m : ℕ) (h : irrational (m + x)) : irrational x := h.of_int_add m
theorem of_add_nat (m : ℕ) (h : irrational (x + m)) : irrational x := h.of_add_int m
theorem nat_add (h : irrational x) (m : ℕ) : irrational (m + x) := h.int_add m
theorem add_nat (h : irrational x) (m : ℕ) : irrational (x + m) := h.add_int m
/-!
#### Negation
-/
theorem of_neg (h : irrational (-x)) : irrational x :=
λ ⟨q, hx⟩, h ⟨-q, by rw [cast_neg, hx]⟩
protected theorem neg (h : irrational x) : irrational (-x) :=
of_neg $ by rwa neg_neg
/-!
#### Subtraction of rational/integer/natural numbers
-/
theorem sub_rat (h : irrational x) : irrational (x - q) :=
by simpa only [sub_eq_add_neg, cast_neg] using h.add_rat (-q)
theorem rat_sub (h : irrational x) : irrational (q - x) :=
by simpa only [sub_eq_add_neg] using h.neg.rat_add q
theorem of_sub_rat (h : irrational (x - q)) : irrational x :=
(of_add_rat (-q) $ by simpa only [cast_neg, sub_eq_add_neg] using h)
theorem of_rat_sub (h : irrational (q - x)) : irrational x :=
of_neg (of_rat_add q (by simpa only [sub_eq_add_neg] using h))
theorem sub_int (h : irrational x) (m : ℤ) : irrational (x - m) :=
by simpa only [rat.cast_coe_int] using h.sub_rat m
theorem int_sub (h : irrational x) (m : ℤ) : irrational (m - x) :=
by simpa only [rat.cast_coe_int] using h.rat_sub m
theorem of_sub_int (m : ℤ) (h : irrational (x - m)) : irrational x :=
of_sub_rat m $ by rwa rat.cast_coe_int
theorem of_int_sub (m : ℤ) (h : irrational (m - x)) : irrational x :=
of_rat_sub m $ by rwa rat.cast_coe_int
theorem sub_nat (h : irrational x) (m : ℕ) : irrational (x - m) := h.sub_int m
theorem nat_sub (h : irrational x) (m : ℕ) : irrational (m - x) := h.int_sub m
theorem of_sub_nat (m : ℕ) (h : irrational (x - m)) : irrational x := h.of_sub_int m
theorem of_nat_sub (m : ℕ) (h : irrational (m - x)) : irrational x := h.of_int_sub m
/-!
#### Multiplication by rational numbers
-/
theorem mul_cases : irrational (x * y) → irrational x ∨ irrational y :=
begin
delta irrational,
contrapose!,
rintros ⟨⟨rx, rfl⟩, ⟨ry, rfl⟩⟩,
exact ⟨rx * ry, cast_mul rx ry⟩
end
theorem of_mul_rat (h : irrational (x * q)) : irrational x :=
h.mul_cases.resolve_right q.not_irrational
theorem mul_rat (h : irrational x) {q : ℚ} (hq : q ≠ 0) : irrational (x * q) :=
of_mul_rat q⁻¹ $ by rwa [mul_assoc, ← cast_mul, mul_inv_cancel hq, cast_one, mul_one]
theorem of_rat_mul : irrational (q * x) → irrational x :=
mul_comm x q ▸ of_mul_rat q
theorem rat_mul (h : irrational x) {q : ℚ} (hq : q ≠ 0) : irrational (q * x) :=
mul_comm x q ▸ h.mul_rat hq
theorem of_mul_int (m : ℤ) (h : irrational (x * m)) : irrational x :=
of_mul_rat m $ by rwa cast_coe_int
theorem of_int_mul (m : ℤ) (h : irrational (m * x)) : irrational x :=
of_rat_mul m $ by rwa cast_coe_int
theorem mul_int (h : irrational x) {m : ℤ} (hm : m ≠ 0) : irrational (x * m) :=
by { rw ← cast_coe_int, refine h.mul_rat _, rwa int.cast_ne_zero }
theorem int_mul (h : irrational x) {m : ℤ} (hm : m ≠ 0) : irrational (m * x) :=
mul_comm x m ▸ h.mul_int hm
theorem of_mul_nat (m : ℕ) (h : irrational (x * m)) : irrational x := h.of_mul_int m
theorem of_nat_mul (m : ℕ) (h : irrational (m * x)) : irrational x := h.of_int_mul m
theorem mul_nat (h : irrational x) {m : ℕ} (hm : m ≠ 0) : irrational (x * m) :=
h.mul_int $ int.coe_nat_ne_zero.2 hm
theorem nat_mul (h : irrational x) {m : ℕ} (hm : m ≠ 0) : irrational (m * x) :=
h.int_mul $ int.coe_nat_ne_zero.2 hm
/-!
#### Inverse
-/
theorem of_inv (h : irrational x⁻¹) : irrational x :=
λ ⟨q, hq⟩, h $ hq ▸ ⟨q⁻¹, q.cast_inv⟩
protected theorem inv (h : irrational x) : irrational x⁻¹ :=
of_inv $ by rwa inv_inv
/-!
#### Division
-/
theorem div_cases (h : irrational (x / y)) : irrational x ∨ irrational y :=
h.mul_cases.imp id of_inv
theorem of_rat_div (h : irrational (q / x)) : irrational x :=
(h.of_rat_mul q).of_inv
theorem of_div_rat (h : irrational (x / q)) : irrational x :=
h.div_cases.resolve_right q.not_irrational
theorem rat_div (h : irrational x) {q : ℚ} (hq : q ≠ 0) : irrational (q / x) := h.inv.rat_mul hq
theorem div_rat (h : irrational x) {q : ℚ} (hq : q ≠ 0) : irrational (x / q) :=
by { rw [div_eq_mul_inv, ← cast_inv], exact h.mul_rat (inv_ne_zero hq) }
theorem of_int_div (m : ℤ) (h : irrational (m / x)) : irrational x :=
h.div_cases.resolve_left m.not_irrational
theorem of_div_int (m : ℤ) (h : irrational (x / m)) : irrational x :=
h.div_cases.resolve_right m.not_irrational
theorem int_div (h : irrational x) {m : ℤ} (hm : m ≠ 0) : irrational (m / x) :=
h.inv.int_mul hm
theorem div_int (h : irrational x) {m : ℤ} (hm : m ≠ 0) : irrational (x / m) :=
by { rw ← cast_coe_int, refine h.div_rat _, rwa int.cast_ne_zero }
theorem of_nat_div (m : ℕ) (h : irrational (m / x)) : irrational x := h.of_int_div m
theorem of_div_nat (m : ℕ) (h : irrational (x / m)) : irrational x := h.of_div_int m
theorem nat_div (h : irrational x) {m : ℕ} (hm : m ≠ 0) : irrational (m / x) := h.inv.nat_mul hm
theorem div_nat (h : irrational x) {m : ℕ} (hm : m ≠ 0) : irrational (x / m) :=
h.div_int $ by rwa int.coe_nat_ne_zero
theorem of_one_div (h : irrational (1 / x)) : irrational x :=
of_rat_div 1 $ by rwa [cast_one]
/-!
#### Natural and integerl power
-/
theorem of_mul_self (h : irrational (x * x)) : irrational x :=
h.mul_cases.elim id id
theorem of_pow : ∀ n : ℕ, irrational (x^n) → irrational x
| 0 := λ h, by { rw pow_zero at h, exact (h ⟨1, cast_one⟩).elim }
| (n+1) := λ h, by { rw pow_succ at h, exact h.mul_cases.elim id (of_pow n) }
theorem of_zpow : ∀ m : ℤ, irrational (x^m) → irrational x
| (n:ℕ) := λ h, by { rw zpow_coe_nat at h, exact h.of_pow _ }
| -[1+n] := λ h, by { rw zpow_neg_succ_of_nat at h, exact h.of_inv.of_pow _ }
end irrational
section polynomial
open polynomial
open_locale polynomial
variables (x : ℝ) (p : ℤ[X])
lemma one_lt_nat_degree_of_irrational_root (hx : irrational x) (p_nonzero : p ≠ 0)
(x_is_root : aeval x p = 0) : 1 < p.nat_degree :=
begin
by_contra rid,
rcases exists_eq_X_add_C_of_nat_degree_le_one (not_lt.1 rid) with ⟨a, b, rfl⟩, clear rid,
have : (a : ℝ) * x = -b, by simpa [eq_neg_iff_add_eq_zero] using x_is_root,
rcases em (a = 0) with (rfl|ha),
{ obtain rfl : b = 0, by simpa,
simpa using p_nonzero },
{ rw [mul_comm, ← eq_div_iff_mul_eq, eq_comm] at this,
refine hx ⟨-b / a, _⟩,
assumption_mod_cast, assumption_mod_cast }
end
end polynomial
section
variables {q : ℚ} {m : ℤ} {n : ℕ} {x : ℝ}
open irrational
/-!
### Simplification lemmas about operations
-/
@[simp] theorem irrational_rat_add_iff : irrational (q + x) ↔ irrational x :=
⟨of_rat_add q, rat_add q⟩
@[simp] theorem irrational_int_add_iff : irrational (m + x) ↔ irrational x :=
⟨of_int_add m, λ h, h.int_add m⟩
@[simp] theorem irrational_nat_add_iff : irrational (n + x) ↔ irrational x :=
⟨of_nat_add n, λ h, h.nat_add n⟩
@[simp] theorem irrational_add_rat_iff : irrational (x + q) ↔ irrational x :=
⟨of_add_rat q, add_rat q⟩
@[simp] theorem irrational_add_int_iff : irrational (x + m) ↔ irrational x :=
⟨of_add_int m, λ h, h.add_int m⟩
@[simp] theorem irrational_add_nat_iff : irrational (x + n) ↔ irrational x :=
⟨of_add_nat n, λ h, h.add_nat n⟩
@[simp] theorem irrational_rat_sub_iff : irrational (q - x) ↔ irrational x :=
⟨of_rat_sub q, rat_sub q⟩
@[simp] theorem irrational_int_sub_iff : irrational (m - x) ↔ irrational x :=
⟨of_int_sub m, λ h, h.int_sub m⟩
@[simp] theorem irrational_nat_sub_iff : irrational (n - x) ↔ irrational x :=
⟨of_nat_sub n, λ h, h.nat_sub n⟩
@[simp] theorem irrational_sub_rat_iff : irrational (x - q) ↔ irrational x :=
⟨of_sub_rat q, sub_rat q⟩
@[simp] theorem irrational_sub_int_iff : irrational (x - m) ↔ irrational x :=
⟨of_sub_int m, λ h, h.sub_int m⟩
@[simp] theorem irrational_sub_nat_iff : irrational (x - n) ↔ irrational x :=
⟨of_sub_nat n, λ h, h.sub_nat n⟩
@[simp] theorem irrational_neg_iff : irrational (-x) ↔ irrational x :=
⟨of_neg, irrational.neg⟩
@[simp] theorem irrational_inv_iff : irrational x⁻¹ ↔ irrational x :=
⟨of_inv, irrational.inv⟩
@[simp] theorem irrational_rat_mul_iff : irrational (q * x) ↔ q ≠ 0 ∧ irrational x :=
⟨λ h, ⟨rat.cast_ne_zero.1 $ left_ne_zero_of_mul h.ne_zero, h.of_rat_mul q⟩, λ h, h.2.rat_mul h.1⟩
@[simp] theorem irrational_mul_rat_iff : irrational (x * q) ↔ q ≠ 0 ∧ irrational x :=
by rw [mul_comm, irrational_rat_mul_iff]
@[simp] theorem irrational_int_mul_iff : irrational (m * x) ↔ m ≠ 0 ∧ irrational x :=
by rw [← cast_coe_int, irrational_rat_mul_iff, int.cast_ne_zero]
@[simp] theorem irrational_mul_int_iff : irrational (x * m) ↔ m ≠ 0 ∧ irrational x :=
by rw [← cast_coe_int, irrational_mul_rat_iff, int.cast_ne_zero]
@[simp] theorem irrational_nat_mul_iff : irrational (n * x) ↔ n ≠ 0 ∧ irrational x :=
by rw [← cast_coe_nat, irrational_rat_mul_iff, nat.cast_ne_zero]
@[simp] theorem irrational_mul_nat_iff : irrational (x * n) ↔ n ≠ 0 ∧ irrational x :=
by rw [← cast_coe_nat, irrational_mul_rat_iff, nat.cast_ne_zero]
@[simp] theorem irrational_rat_div_iff : irrational (q / x) ↔ q ≠ 0 ∧ irrational x :=
by simp [div_eq_mul_inv]
@[simp] theorem irrational_div_rat_iff : irrational (x / q) ↔ q ≠ 0 ∧ irrational x :=
by rw [div_eq_mul_inv, ← cast_inv, irrational_mul_rat_iff, ne.def, inv_eq_zero]
@[simp] theorem irrational_int_div_iff : irrational (m / x) ↔ m ≠ 0 ∧ irrational x :=
by simp [div_eq_mul_inv]
@[simp] theorem irrational_div_int_iff : irrational (x / m) ↔ m ≠ 0 ∧ irrational x :=
by rw [← cast_coe_int, irrational_div_rat_iff, int.cast_ne_zero]
@[simp] theorem irrational_nat_div_iff : irrational (n / x) ↔ n ≠ 0 ∧ irrational x :=
by simp [div_eq_mul_inv]
@[simp] theorem irrational_div_nat_iff : irrational (x / n) ↔ n ≠ 0 ∧ irrational x :=
by rw [← cast_coe_nat, irrational_div_rat_iff, nat.cast_ne_zero]
/-- There is an irrational number `r` between any two reals `x < r < y`. -/
theorem exists_irrational_btwn {x y : ℝ} (h : x < y) :
∃ r, irrational r ∧ x < r ∧ r < y :=
let ⟨q, ⟨hq1, hq2⟩⟩ := (exists_rat_btwn ((sub_lt_sub_iff_right (real.sqrt 2)).mpr h)) in
⟨q + real.sqrt 2, irrational_sqrt_two.rat_add _,
sub_lt_iff_lt_add.mp hq1, lt_sub_iff_add_lt.mp hq2⟩
end
|
lemma coeffs_map_poly [code abstract]: "coeffs (map_poly f p) = strip_while ((=) 0) (map f (coeffs p))" |
informal statement Let $V$ be a vector space which is spanned by a countably infinite set. Prove that every linearly independent subset of $V$ is finite or countably infinite.formal statement theorem exercise_6_1_14 (G : Type*) [group G]
(hG : is_cyclic $ G ⧸ (center G)) :
center G = ⊤ := |
theorem very_easy : true :=
begin
sorry
end
|
/-
Copyright (c) 2021 Ashvni Narayanan. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ashvni Narayanan
-/
import tendsto_zero_of_sum_even_char
--import p_adic_L_function_def
-- import general_bernoulli_number.basic
-- import topology.algebra.nonarchimedean.bases
-- import chinese_remainder_units
/-!
# A convergence property regarding (ℤ/dp^n ℤ)ˣ
This file proves the third sum in the proof of Theorem 12.2 in Introduction to Cyclotomic Fields, Washington.
It gives a convergence property relating to generalized Bernoulli numbers.
# Main Theorems
* `W`
## Tags
p-adic, L-function, Bernoulli measure, Dirichlet character
-/
open_locale big_operators
local attribute [instance] zmod.topological_space
open filter dirichlet_character
open_locale topological_space
open_locale big_operators
variables {p : ℕ} [fact (nat.prime p)] {d : ℕ} [fact (0 < d)] {R : Type*} [normed_comm_ring R] (m : ℕ)
(hd : d.gcd p = 1) (χ : dirichlet_character R (d*(p^m))) {c : ℕ} (hc : c.gcd p = 1)
(hc' : c.gcd d = 1) (na : ∀ (n : ℕ) (f : ℕ → R), ∥ ∑ (i : ℕ) in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥)
variables (p d R) [complete_space R] [char_zero R]
open continuous_map
variables [normed_algebra ℚ_[p] R] [fact (0 < m)]
variable [fact (0 < d)]
open dirichlet_character
variable (hd)
open zmod
variable (c)
variables (hc) (hc')
lemma W [no_zero_divisors R] [algebra ℚ R] [norm_one_class R] (hd : d.coprime p) (hp : 2 < p)
(na' : ∀ (n : ℕ) (f : (zmod n)ˣ → R), ∥∑ i : (zmod n)ˣ, f i∥ ≤ ⨆ (i : (zmod n)ˣ), ∥f i∥)
(na : ∀ (n : ℕ) (f : ℕ → R), ∥∑ i in finset.range n, f i∥ ≤ ⨆ (i : zmod n), ∥f i.val∥)
(n : ℕ) (hn : 1 < n) (hχ : χ.is_even) :
filter.tendsto (λ j : ℕ, ∑ (x : (zmod (d * p ^ j))ˣ),
((asso_dirichlet_character (χ.mul (teichmuller_character_mod_p' p R^n)) x : R) *
((((x : zmod (d * p^j))).val)^(n - 1) : R)) • (algebra_map ℚ R) ((↑c - 1) / 2)) filter.at_top (nhds 0) :=
begin
simp_rw [smul_eq_mul, ← finset.sum_mul],
conv { congr, skip, skip, congr, rw ← zero_mul ((algebra_map ℚ R) ((↑c - 1) / 2)), },
apply tendsto.mul_const,
simp_rw zmod.nat_cast_val, simp_rw ← coe_coe,
convert (tendsto_congr' _).1 (sum_even_character_tendsto_zero_of_units na' hn hχ hp),
rw eventually_eq, rw eventually_at_top,
refine ⟨m, λ y hy, _⟩,
apply finset.sum_congr rfl,
intros z hz,
conv_lhs { congr, rw coe_coe, rw ← zmod.nat_cast_val, },
rw zmod.nat_cast_val, rw ← coe_coe,
end
|
import .affine_space_type
import .affine_frame
import data.real.basic
def reals_as_affine_space := affine_space_type
ℝ
ℝ
ℝ
#check reals_as_affine_space
def reals_as_affine_space_1 : reals_as_affine_space := ⟨⟩
def reals_as_affine_space_2 : reals_as_affine_space := ⟨⟩
example : reals_as_affine_space_1 = reals_as_affine_space_2 := rfl
def a_frame : affine_frame ℝ ℝ ℝ (fin 1) :=
⟨(0 : ℝ),
(λ (n : fin 1), 1),
sorry ⟩
/-
A few things to note:
(1) We can specialize our generic affine_space_type definition
(2) We can't instantiate disjoint affine space of the same type
(3) Can we express news points and vectors in terms of this frame?
-/ |
[STATEMENT]
lemma min_enat_simps [simp]:
"min (enat m) (enat n) = enat (min m n)"
"min q 0 = 0"
"min 0 q = 0"
"min q (\<infinity>::enat) = q"
"min (\<infinity>::enat) q = q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
1. (min (enat m) (enat n) = enat (min m n) &&& min q 0 = 0) &&& min 0 q = 0 &&& min q \<infinity> = q &&& min \<infinity> q = q
[PROOF STEP]
by (auto simp add: min_def) |
/-
Copyright (c) 2021 Alain Verberkmoes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Alain Verberkmoes
-/
import data.int.basic
/-!
# IMO 2011 Q5
Let `f` be a function from the set of integers to the set
of positive integers. Suppose that, for any two integers
`m` and `n`, the difference `f(m) − f(n)` is divisible by
`f(m − n)`. Prove that, for all integers `m` and `n` with
`f(m) ≤ f(n)`, the number `f(n)` is divisible by `f(m)`.
-/
open int
theorem imo2011_q5 (f : ℤ → ℤ) (hpos : ∀ n : ℤ, 0 < f n)
(hdvd : ∀ m n : ℤ, f (m - n) ∣ f m - f n) :
∀ m n : ℤ, f m ≤ f n → f m ∣ f n :=
begin
intros m n h_fm_le_fn,
cases lt_or_eq_of_le h_fm_le_fn with h_fm_lt_fn h_fm_eq_fn,
{ -- m < n
let d := f m - f (m - n),
have h_fn_dvd_d : f n ∣ d,
{ rw ←sub_sub_self m n,
exact hdvd m (m - n) },
have h_d_lt_fn : d < f n,
{ calc d < f m : sub_lt_self _ (hpos (m - n))
... < f n : h_fm_lt_fn },
have h_neg_d_lt_fn : -d < f n,
{ calc -d = f (m - n) - f m : neg_sub _ _
... < f (m - n) : sub_lt_self _ (hpos m)
... ≤ f n - f m : le_of_dvd (sub_pos.mpr h_fm_lt_fn) _
... < f n : sub_lt_self _ (hpos m),
-- ⊢ f (m - n) ∣ f n - f m
rw [←dvd_neg, neg_sub], exact hdvd m n },
have h_d_eq_zero : d = 0,
{ obtain (hd | hd | hd) : d > 0 ∨ d = 0 ∨ d < 0 := trichotomous d 0,
{ -- d > 0
have h₁ : f n ≤ d, from le_of_dvd hd h_fn_dvd_d,
have h₂ : ¬ f n ≤ d, from not_le.mpr h_d_lt_fn,
contradiction },
{ -- d = 0
exact hd },
{ -- d < 0
have h₁ : f n ≤ -d, from le_of_dvd (neg_pos.mpr hd) ((dvd_neg _ _).mpr h_fn_dvd_d),
have h₂ : ¬ f n ≤ -d, from not_le.mpr h_neg_d_lt_fn,
contradiction } },
have h₁ : f m = f (m - n), from sub_eq_zero.mp h_d_eq_zero,
have h₂ : f (m - n) ∣ f m - f n, from hdvd m n,
rw ←h₁ at h₂,
exact (dvd_iff_dvd_of_dvd_sub h₂).mp dvd_rfl },
{ -- m = n
rw h_fm_eq_fn }
end
|
import Mathlib.Data.Rat.Order
import Mathlib.Tactic.Ring
/- 4 points -/
theorem problem1 {x : ℚ} (hx : x = 2/3) : 3 * x ≠ 1 := by
apply ne_of_gt
calc 3 * x = 3 * (2 / 3) := by rw [hx]
_ > 1 := by rfl
/- 5 points -/
theorem problem2 {x y : ℚ} (h : x = 1 ∨ y = -1) :
x * y + x = y + 1 := by
cases' h with hx hy
. calc x * y + x = 1 * y + 1 := by rw [hx]
_ = y + 1 := by ring
. calc x * y + x = x * -1 + x := by rw [hy]
_ = -1 + 1 := by ring
_ = y + 1 := by rw [hy]
/- 1 point -/
theorem problem3 {x : ℚ} (hx : 2 * x + 1 = 5) :
2 * x = 2 ∨ 2 * x = 4 := by
right
calc 2 * x = (2 * x + 1) - 1 := by ring
_ = 5 - 1 := by rw [hx]
_ = 4 := by norm_num |
{-# OPTIONS --rewriting #-}
postulate
_↦_ : {A : Set} → A → A → Set
idr : {A : Set} {a : A} → a ↦ a
{-# BUILTIN REWRITE _↦_ #-}
record _×_ (A B : Set) : Set where
constructor _,_
field
fst : A
snd : B
postulate
A B C : Set
g : A → B → C
f : A × B → C
f (x , y) = g x y
postulate
D : Set
P : (A → B → C) → D
res : D
rew : P (λ x y → g x y) ↦ res
{-# REWRITE rew #-}
test : P (λ x y → f (x , y)) ↦ res
test = idr
|
/-
Description : Formalization of islanders problem for two people.
Copyright : (c) Daniel Selsam, 2018
License : GPL-3
-/
import .util .knows .problem
theorem islanders_n2 : islanders 2 :=
assume everyone_sees :
∀ (d₁ d₂ : day) (p₁ p₂ : person), p₂ ≠ p₁ → common_knowledge (is_marked p₂ → knows d₂ p₁ (is_marked p₂)) d₁
∧ common_knowledge (¬ is_marked p₂ → knows d₂ p₁ (¬ is_marked p₂)) d₁,
assume oracle :
∀ (d : day) (p : person) (k : ℕ), common_knowledge (knows (d+1) p (reduce_or (list.map is_marked (list.range 2)))) (d+1+k),
assume nobody_leaves :
∀ (d : day) (p : person), d+1 < 2 → common_knowledge (¬ knows (d+1) p (is_marked p)) (d+2),
have H1 : knows 1 1 (¬ is_marked 1 → knows 1 0 (is_marked 0 ∨ is_marked 1)), from
knows_lam 1 1 1 [] (λ _, oracle 0 0 0 [1]),
have H2 : knows 1 1 (¬ is_marked 1 → knows 1 0 (¬ is_marked 1)), from
and.right (everyone_sees 1 1 0 1 (ne.symm nat.zero_ne_one)) [1],
have H3 : knows 1 1 (¬ is_marked 1) → knows 1 1 (knows 1 0 (is_marked 0)), from
assume h1 : knows 1 1 (¬ is_marked 1),
show knows 1 1 (knows 1 0 (is_marked 0)), from
have h2 : knows 1 1 (knows 1 0 (is_marked 0 ∨ is_marked 1)), from knows_mp 0 1 1 1 [] [] H1 h1,
have h3 : knows 1 1 (knows 1 0 (¬ is_marked 1)), from knows_mp 0 1 1 1 [] [] H2 h1,
knows_cancel_or 0 _ _ _ [1] [] h2 h3,
have H4 : knows 2 1 (¬ is_marked 1 → knows 1 0 (is_marked 0)), from
knows_persists 0 1 1 [] (knows_lam 0 1 1 [] H3),
have H5 : knows 2 1 (¬ knows 1 0 (is_marked 0)), from
nobody_leaves 0 0 (nat.lt_succ_self 1) [1],
show knows 2 1 (is_marked 1), from
knows_dneg 0 _ _ [] (knows_cancel_imp 0 0 _ _ [] [] H4 H5)
|
lemma of_real_1 [simp]: "of_real 1 = 1" |
/-
Copyright (c) 2020 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Eric Wieser
-/
import algebra.char_p.basic
import ring_theory.ideal.quotient
/-!
# Characteristic of quotients rings
-/
universes u v
namespace char_p
theorem quotient (R : Type u) [comm_ring R] (p : ℕ) [hp1 : fact p.prime] (hp2 : ↑p ∈ nonunits R) :
char_p (R ⧸ (ideal.span {p} : ideal R)) p :=
have hp0 : (p : R ⧸ (ideal.span {p} : ideal R)) = 0,
from (ideal.quotient.mk (ideal.span {p} : ideal R)).map_nat_cast p ▸
ideal.quotient.eq_zero_iff_mem.2 (ideal.subset_span $ set.mem_singleton _),
ring_char.of_eq $ or.resolve_left ((nat.dvd_prime hp1.1).1 $ ring_char.dvd hp0) $ λ h1,
hp2 $ is_unit_iff_dvd_one.2 $ ideal.mem_span_singleton.1 $ ideal.quotient.eq_zero_iff_mem.1 $
@@subsingleton.elim (@@char_p.subsingleton _ $ ring_char.of_eq h1) _ _
/-- If an ideal does not contain any coercions of natural numbers other than zero, then its quotient
inherits the characteristic of the underlying ring. -/
lemma quotient' {R : Type*} [comm_ring R] (p : ℕ) [char_p R p] (I : ideal R)
(h : ∀ x : ℕ, (x : R) ∈ I → (x : R) = 0) :
char_p (R ⧸ I) p :=
⟨λ x, begin
rw [←cast_eq_zero_iff R p x, ←(ideal.quotient.mk I).map_nat_cast],
refine quotient.eq'.trans (_ : ↑x - 0 ∈ I ↔ _),
rw sub_zero,
exact ⟨h x, λ h', h'.symm ▸ I.zero_mem⟩,
end⟩
end char_p
|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Yury Kudryashov
-/
import data.real.sqrt
import data.rat.sqrt
import ring_theory.int.basic
import data.polynomial.eval
import data.polynomial.degree
import tactic.interval_cases
import ring_theory.algebraic
/-!
# Irrational real numbers
In this file we define a predicate `irrational` on `ℝ`, prove that the `n`-th root of an integer
number is irrational if it is not integer, and that `sqrt q` is irrational if and only if
`rat.sqrt q * rat.sqrt q ≠ q ∧ 0 ≤ q`.
We also provide dot-style constructors like `irrational.add_rat`, `irrational.rat_sub` etc.
-/
open rat real multiplicity
/-- A real number is irrational if it is not equal to any rational number. -/
def irrational (x : ℝ) := x ∉ set.range (coe : ℚ → ℝ)
lemma irrational_iff_ne_rational (x : ℝ) : irrational x ↔ ∀ a b : ℤ, x ≠ a / b :=
by simp only [irrational, rat.forall, cast_mk, not_exists, set.mem_range, cast_coe_int, cast_div,
eq_comm]
/-- A transcendental real number is irrational. -/
lemma transcendental.irrational {r : ℝ} (tr : transcendental ℚ r) :
irrational r :=
by { rintro ⟨a, rfl⟩, exact tr (is_algebraic_algebra_map a) }
/-!
### Irrationality of roots of integer and rational numbers
-/
/-- If `x^n`, `n > 0`, is integer and is not the `n`-th power of an integer, then
`x` is irrational. -/
theorem irrational_nrt_of_notint_nrt {x : ℝ} (n : ℕ) (m : ℤ)
(hxr : x ^ n = m) (hv : ¬ ∃ y : ℤ, x = y) (hnpos : 0 < n) :
irrational x :=
begin
rintros ⟨⟨N, D, P, C⟩, rfl⟩,
rw [← cast_pow] at hxr,
have c1 : ((D : ℤ) : ℝ) ≠ 0,
{ rw [int.cast_ne_zero, int.coe_nat_ne_zero], exact ne_of_gt P },
have c2 : ((D : ℤ) : ℝ) ^ n ≠ 0 := pow_ne_zero _ c1,
rw [num_denom', cast_pow, cast_mk, div_pow, div_eq_iff_mul_eq c2,
← int.cast_pow, ← int.cast_pow, ← int.cast_mul, int.cast_inj] at hxr,
have hdivn : ↑D ^ n ∣ N ^ n := dvd.intro_left m hxr,
rw [← int.dvd_nat_abs, ← int.coe_nat_pow, int.coe_nat_dvd, int.nat_abs_pow,
nat.pow_dvd_pow_iff hnpos] at hdivn,
have hD : D = 1 := by rw [← nat.gcd_eq_right hdivn, C.gcd_eq_one],
subst D,
refine hv ⟨N, _⟩,
rw [num_denom', int.coe_nat_one, mk_eq_div, int.cast_one, div_one, cast_coe_int]
end
/-- If `x^n = m` is an integer and `n` does not divide the `multiplicity p m`, then `x`
is irrational. -/
theorem irrational_nrt_of_n_not_dvd_multiplicity {x : ℝ} (n : ℕ) {m : ℤ} (hm : m ≠ 0) (p : ℕ)
[hp : fact p.prime] (hxr : x ^ n = m)
(hv : (multiplicity (p : ℤ) m).get (finite_int_iff.2 ⟨hp.1.ne_one, hm⟩) % n ≠ 0) :
irrational x :=
begin
rcases nat.eq_zero_or_pos n with rfl | hnpos,
{ rw [eq_comm, pow_zero, ← int.cast_one, int.cast_inj] at hxr,
simpa [hxr, multiplicity.one_right (mt is_unit_iff_dvd_one.1
(mt int.coe_nat_dvd.1 hp.1.not_dvd_one)), nat.zero_mod] using hv },
refine irrational_nrt_of_notint_nrt _ _ hxr _ hnpos,
rintro ⟨y, rfl⟩,
rw [← int.cast_pow, int.cast_inj] at hxr, subst m,
have : y ≠ 0, { rintro rfl, rw zero_pow hnpos at hm, exact hm rfl },
erw [multiplicity.pow' (nat.prime_iff_prime_int.1 hp.1)
(finite_int_iff.2 ⟨hp.1.ne_one, this⟩), nat.mul_mod_right] at hv,
exact hv rfl
end
theorem irrational_sqrt_of_multiplicity_odd (m : ℤ) (hm : 0 < m)
(p : ℕ) [hp : fact p.prime]
(Hpv : (multiplicity (p : ℤ) m).get
(finite_int_iff.2 ⟨hp.1.ne_one, (ne_of_lt hm).symm⟩) % 2 = 1) :
irrational (sqrt m) :=
@irrational_nrt_of_n_not_dvd_multiplicity _ 2 _ (ne.symm (ne_of_lt hm)) p hp
(sq_sqrt (int.cast_nonneg.2 $ le_of_lt hm))
(by rw Hpv; exact one_ne_zero)
theorem nat.prime.irrational_sqrt {p : ℕ} (hp : nat.prime p) : irrational (sqrt p) :=
@irrational_sqrt_of_multiplicity_odd p (int.coe_nat_pos.2 hp.pos) p ⟨hp⟩ $
by simp [multiplicity_self (mt is_unit_iff_dvd_one.1 (mt int.coe_nat_dvd.1 hp.not_dvd_one) : _)];
refl
theorem irrational_sqrt_two : irrational (sqrt 2) :=
by simpa using nat.prime_two.irrational_sqrt
theorem irrational_sqrt_rat_iff (q : ℚ) : irrational (sqrt q) ↔
rat.sqrt q * rat.sqrt q ≠ q ∧ 0 ≤ q :=
if H1 : rat.sqrt q * rat.sqrt q = q
then iff_of_false (not_not_intro ⟨rat.sqrt q,
by rw [← H1, cast_mul, sqrt_mul_self (cast_nonneg.2 $ rat.sqrt_nonneg q),
sqrt_eq, abs_of_nonneg (rat.sqrt_nonneg q)]⟩) (λ h, h.1 H1)
else if H2 : 0 ≤ q
then iff_of_true (λ ⟨r, hr⟩, H1 $ (exists_mul_self _).1 ⟨r,
by rwa [eq_comm, sqrt_eq_iff_mul_self_eq (cast_nonneg.2 H2), ← cast_mul, rat.cast_inj] at hr;
rw [← hr]; exact real.sqrt_nonneg _⟩) ⟨H1, H2⟩
else iff_of_false (not_not_intro ⟨0,
by rw cast_zero; exact (sqrt_eq_zero_of_nonpos (rat.cast_nonpos.2 $ le_of_not_le H2)).symm⟩)
(λ h, H2 h.2)
instance (q : ℚ) : decidable (irrational (sqrt q)) :=
decidable_of_iff' _ (irrational_sqrt_rat_iff q)
/-!
### Adding/subtracting/multiplying by rational numbers
-/
lemma rat.not_irrational (q : ℚ) : ¬irrational q := λ h, h ⟨q, rfl⟩
namespace irrational
variables (q : ℚ) {x y : ℝ}
open_locale classical
theorem add_cases : irrational (x + y) → irrational x ∨ irrational y :=
begin
delta irrational,
contrapose!,
rintros ⟨⟨rx, rfl⟩, ⟨ry, rfl⟩⟩,
exact ⟨rx + ry, cast_add rx ry⟩
end
theorem of_rat_add (h : irrational (q + x)) : irrational x :=
h.add_cases.elim (λ h, absurd h q.not_irrational) id
theorem rat_add (h : irrational x) : irrational (q + x) :=
of_rat_add (-q) $ by rwa [cast_neg, neg_add_cancel_left]
theorem of_add_rat : irrational (x + q) → irrational x :=
add_comm ↑q x ▸ of_rat_add q
theorem add_rat (h : irrational x) : irrational (x + q) :=
add_comm ↑q x ▸ h.rat_add q
theorem of_neg (h : irrational (-x)) : irrational x :=
λ ⟨q, hx⟩, h ⟨-q, by rw [cast_neg, hx]⟩
protected theorem neg (h : irrational x) : irrational (-x) :=
of_neg $ by rwa neg_neg
theorem sub_rat (h : irrational x) : irrational (x - q) :=
by simpa only [sub_eq_add_neg, cast_neg] using h.add_rat (-q)
theorem rat_sub (h : irrational x) : irrational (q - x) :=
by simpa only [sub_eq_add_neg] using h.neg.rat_add q
theorem of_sub_rat (h : irrational (x - q)) : irrational x :=
(of_add_rat (-q) $ by simpa only [cast_neg, sub_eq_add_neg] using h)
theorem of_rat_sub (h : irrational (q - x)) : irrational x :=
of_neg (of_rat_add q (by simpa only [sub_eq_add_neg] using h))
theorem mul_cases : irrational (x * y) → irrational x ∨ irrational y :=
begin
delta irrational,
contrapose!,
rintros ⟨⟨rx, rfl⟩, ⟨ry, rfl⟩⟩,
exact ⟨rx * ry, cast_mul rx ry⟩
end
theorem of_mul_rat (h : irrational (x * q)) : irrational x :=
h.mul_cases.elim id (λ h, absurd h q.not_irrational)
theorem mul_rat (h : irrational x) {q : ℚ} (hq : q ≠ 0) : irrational (x * q) :=
of_mul_rat q⁻¹ $ by rwa [mul_assoc, ← cast_mul, mul_inv_cancel hq, cast_one, mul_one]
theorem of_rat_mul : irrational (q * x) → irrational x :=
mul_comm x q ▸ of_mul_rat q
theorem rat_mul (h : irrational x) {q : ℚ} (hq : q ≠ 0) : irrational (q * x) :=
mul_comm x q ▸ h.mul_rat hq
theorem of_mul_self (h : irrational (x * x)) : irrational x :=
h.mul_cases.elim id id
theorem of_inv (h : irrational x⁻¹) : irrational x :=
λ ⟨q, hq⟩, h $ hq ▸ ⟨q⁻¹, q.cast_inv⟩
protected theorem inv (h : irrational x) : irrational x⁻¹ :=
of_inv $ by rwa inv_inv'
theorem div_cases (h : irrational (x / y)) : irrational x ∨ irrational y :=
h.mul_cases.imp id of_inv
theorem of_rat_div (h : irrational (q / x)) : irrational x :=
(h.of_rat_mul q).of_inv
theorem of_one_div (h : irrational (1 / x)) : irrational x :=
of_rat_div 1 $ by rwa [cast_one]
theorem of_pow : ∀ n : ℕ, irrational (x^n) → irrational x
| 0 := λ h, by { rw pow_zero at h, exact (h ⟨1, cast_one⟩).elim }
| (n+1) := λ h, by { rw pow_succ at h, exact h.mul_cases.elim id (of_pow n) }
theorem of_fpow : ∀ m : ℤ, irrational (x^m) → irrational x
| (n:ℕ) := of_pow n
| -[1+n] := λ h, by { rw gpow_neg_succ_of_nat at h, exact h.of_inv.of_pow _ }
end irrational
section polynomial
open polynomial
variables (x : ℝ) (p : polynomial ℤ)
lemma one_lt_nat_degree_of_irrational_root (hx : irrational x) (p_nonzero : p ≠ 0)
(x_is_root : aeval x p = 0) : 1 < p.nat_degree :=
begin
by_contra rid,
rcases exists_eq_X_add_C_of_nat_degree_le_one (not_lt.1 rid) with ⟨a, b, rfl⟩, clear rid,
have : (a : ℝ) * x = -b, by simpa [eq_neg_iff_add_eq_zero] using x_is_root,
rcases em (a = 0) with (rfl|ha),
{ obtain rfl : b = 0, by simpa,
simpa using p_nonzero },
{ rw [mul_comm, ← eq_div_iff_mul_eq, eq_comm] at this,
refine hx ⟨-b / a, _⟩,
assumption_mod_cast, assumption_mod_cast }
end
end polynomial
section
variables {q : ℚ} {x : ℝ}
open irrational
@[simp] theorem irrational_rat_add_iff : irrational (q + x) ↔ irrational x :=
⟨of_rat_add q, rat_add q⟩
@[simp] theorem irrational_add_rat_iff : irrational (x + q) ↔ irrational x :=
⟨of_add_rat q, add_rat q⟩
@[simp] theorem irrational_rat_sub_iff : irrational (q - x) ↔ irrational x :=
⟨of_rat_sub q, rat_sub q⟩
@[simp] theorem irrational_sub_rat_iff : irrational (x - q) ↔ irrational x :=
⟨of_sub_rat q, sub_rat q⟩
@[simp] theorem irrational_neg_iff : irrational (-x) ↔ irrational x :=
⟨of_neg, irrational.neg⟩
@[simp] theorem irrational_inv_iff : irrational x⁻¹ ↔ irrational x :=
⟨of_inv, irrational.inv⟩
end
|
informal statement If $s_{1}=\sqrt{2}$, and $s_{n+1}=\sqrt{2+\sqrt{s_{n}}} \quad(n=1,2,3, \ldots),$ prove that $\left\{s_{n}\right\}$ converges, and that $s_{n}<2$ for $n=1,2,3, \ldots$.formal statement theorem exercise_3_6a
: tendsto (λ (n : ℕ), (∑ i in finset.range n, g i)) at_top at_top := |
lemmas has_derivative_Im [derivative_intros] = bounded_linear.has_derivative[OF bounded_linear_Im] |
informal statement Let $f$ and $g$ be continuous mappings of a metric space $X$ into a metric space $Y$, and let $E$ be a dense subset of $X$. Prove that $f(E)$ is dense in $f(X)$.formal statement theorem exercise_4_4a
{α : Type} [metric_space α]
{β : Type} [metric_space β]
(f : α → β)
(s : set α)
(h₁ : continuous f)
(h₂ : dense s)
: f '' set.univ ⊆ closure (f '' s) := |
import tactic
-- the next two lines let us use the law of the excluded middle without trouble
noncomputable theory
open_locale classical
--BEGIN--
/--------------------------------------------------------------------------
Delete the ``sorry,`` below and replace them with a legitimate proof.
--------------------------------------------------------------------------/
-- camper is a type.
-- If x : camper then x is a camper in the main lounge.
-- singing(x) is inhabited if x is singing
theorem math_campers_singing_paradox
(camper : Type)
(singing : camper → Prop)
(alice : camper) -- making sure that there is at least one camper in the lounge
: ∃ x : camper, (singing x → (∀ y : camper, singing y)) :=
begin
sorry,
end
--END-- |
Subsets and Splits