Theorem: groupBySubtractive_spec4 (Table/Proofs.lean)

State before:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
⊢ ∀ (t : Table sch) (c : η) (hc : Schema.HasCol (c, τ) sch),
    List.NoDuplicates (getColumn2 (groupBySubtractive t c) "key")
Tactic:
intros t c hc
State after:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates (getColumn2 (groupBySubtractive t c) "key")

State before:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates (getColumn2 (groupBySubtractive t c) "key")
Tactic:
simp only [groupBySubtractive, groupBy, getColumn2]
State after:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map (fun r => getValue r "key")
      (List.map
        (fun klv =>
          Row.cons (Cell.fromOption (Option.map ULift.up klv.fst))
            (Row.cons (Cell.val { rows := List.map (fun r => Row.removeColumn (Schema.colImpliesName hc) r) klv.snd })
              Row.nil))
        (List.groupByKey (List.map (fun r => (getValue r c, r)) t.rows))))

State before:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map (fun r => getValue r "key")
      (List.map
        (fun klv =>
          Row.cons (Cell.fromOption (Option.map ULift.up klv.fst))
            (Row.cons (Cell.val { rows := List.map (fun r => Row.removeColumn (Schema.colImpliesName hc) r) klv.snd })
              Row.nil))
        (List.groupByKey (List.map (fun r => (getValue r c, r)) t.rows))))
Tactic:
rw [List.map_map]
State after:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map
      ((fun r => getValue r "key") ∘ fun klv =>
        Row.cons (Cell.fromOption (Option.map ULift.up klv.fst))
          (Row.cons (Cell.val { rows := List.map (fun r => Row.removeColumn (Schema.colImpliesName hc) r) klv.snd })
            Row.nil))
      (List.groupByKey (List.map (fun r => (getValue r c, r)) t.rows)))

State before:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map
      ((fun r => getValue r "key") ∘ fun klv =>
        Row.cons (Cell.fromOption (Option.map ULift.up klv.fst))
          (Row.cons (Cell.val { rows := List.map (fun r => Row.removeColumn (Schema.colImpliesName hc) r) klv.snd })
            Row.nil))
      (List.groupByKey (List.map (fun r => (getValue r c, r)) t.rows)))
Tactic:
simp only [Function.comp, getValue]
State after:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map
      ((fun r => Cell.toOption (Row.getCell r Schema.HasCol.hd)) ∘ fun klv =>
        Row.cons (Cell.fromOption (Option.map ULift.up klv.fst))
          (Row.cons (Cell.val { rows := List.map (fun r => Row.removeColumn (Schema.colImpliesName hc) r) klv.snd })
            Row.nil))
      (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows)))

State before:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map
      ((fun r => Cell.toOption (Row.getCell r Schema.HasCol.hd)) ∘ fun klv =>
        Row.cons (Cell.fromOption (Option.map ULift.up klv.fst))
          (Row.cons (Cell.val { rows := List.map (fun r => Row.removeColumn (Schema.colImpliesName hc) r) klv.snd })
            Row.nil))
      (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows)))
Tactic:
conv =>
  rhs
  lhs
  apply funext (g := _) _
  apply (λ x => Option.map ULift.up x.fst)
  apply (λ x => Cell.toOption_fromOption _)
State after:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map (fun x => Option.map ULift.up x.fst)
      (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows)))

State before:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map (fun x => Option.map ULift.up x.fst)
      (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows)))
Tactic:
conv =>
  rhs
  lhs
  apply funext (g := _) _
  apply (λ x => Option.map ULift.up ∘ Prod.fst)
  apply (λ x => rfl)
State after:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map ((fun x => Option.map ULift.up ∘ Prod.fst) (Row sch))
      (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows)))

State before:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map ((fun x => Option.map ULift.up ∘ Prod.fst) (Row sch))
      (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows)))
Tactic:
rw [←List.map_map]
State after:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map (Option.map ULift.up)
      (List.map Prod.fst (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows))))

State before:
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map (Option.map ULift.up)
      (List.map Prod.fst (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows))))
Tactic:
apply List.no_dups_map_injective
State after:
case hf
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ Function.injective (Option.map ULift.up)

case hxs
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map Prod.fst (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows)))

State before:
case hf
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ Function.injective (Option.map ULift.up)

case hxs
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map Prod.fst (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows)))
Tactic:
. intros x y hxy
  cases x
  . cases y
    . rfl
    . contradiction
  . cases y
    . contradiction
    . cases hxy; rfl
State after:
case hxs
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map Prod.fst (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows)))

State before:
case hxs
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map Prod.fst (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows)))
Tactic:
. apply List.groupByKey_fsts_no_duplicates
State after:
no goals

State before:
case hf
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ Function.injective (Option.map ULift.up)
Tactic:
intros x y hxy
State after:
case hf
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
x y : Option τ
hxy : Option.map ULift.up x = Option.map ULift.up y
⊢ x = y

State before:
case hf
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
x y : Option τ
hxy : Option.map ULift.up x = Option.map ULift.up y
⊢ x = y
Tactic:
cases x
State after:
case hf.none
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
y : Option τ
hxy : Option.map ULift.up none = Option.map ULift.up y
⊢ none = y

case hf.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
y : Option τ
val✝ : τ
hxy : Option.map ULift.up (some val✝) = Option.map ULift.up y
⊢ some val✝ = y

State before:
case hf.none
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
y : Option τ
hxy : Option.map ULift.up none = Option.map ULift.up y
⊢ none = y

case hf.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
y : Option τ
val✝ : τ
hxy : Option.map ULift.up (some val✝) = Option.map ULift.up y
⊢ some val✝ = y
Tactic:
. cases y
  . rfl
  . contradiction
State after:
case hf.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
y : Option τ
val✝ : τ
hxy : Option.map ULift.up (some val✝) = Option.map ULift.up y
⊢ some val✝ = y

State before:
case hf.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
y : Option τ
val✝ : τ
hxy : Option.map ULift.up (some val✝) = Option.map ULift.up y
⊢ some val✝ = y
Tactic:
. cases y
  . contradiction
  . cases hxy; rfl
State after:
no goals

State before:
case hf.none
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
y : Option τ
hxy : Option.map ULift.up none = Option.map ULift.up y
⊢ none = y
Tactic:
cases y
State after:
case hf.none.none
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
hxy : Option.map ULift.up none = Option.map ULift.up none
⊢ none = none

case hf.none.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝ : τ
hxy : Option.map ULift.up none = Option.map ULift.up (some val✝)
⊢ none = some val✝

State before:
case hf.none.none
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
hxy : Option.map ULift.up none = Option.map ULift.up none
⊢ none = none

case hf.none.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝ : τ
hxy : Option.map ULift.up none = Option.map ULift.up (some val✝)
⊢ none = some val✝
Tactic:
. rfl
State after:
case hf.none.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝ : τ
hxy : Option.map ULift.up none = Option.map ULift.up (some val✝)
⊢ none = some val✝

State before:
case hf.none.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝ : τ
hxy : Option.map ULift.up none = Option.map ULift.up (some val✝)
⊢ none = some val✝
Tactic:
. contradiction
State after:
no goals

State before:
case hf.none.none
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
hxy : Option.map ULift.up none = Option.map ULift.up none
⊢ none = none
Tactic:
rfl
State after:
no goals

State before:
case hf.none.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝ : τ
hxy : Option.map ULift.up none = Option.map ULift.up (some val✝)
⊢ none = some val✝
Tactic:
contradiction
State after:
no goals

State before:
case hf.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
y : Option τ
val✝ : τ
hxy : Option.map ULift.up (some val✝) = Option.map ULift.up y
⊢ some val✝ = y
Tactic:
cases y
State after:
case hf.some.none
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝ : τ
hxy : Option.map ULift.up (some val✝) = Option.map ULift.up none
⊢ some val✝ = none

case hf.some.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝¹ val✝ : τ
hxy : Option.map ULift.up (some val✝¹) = Option.map ULift.up (some val✝)
⊢ some val✝¹ = some val✝

State before:
case hf.some.none
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝ : τ
hxy : Option.map ULift.up (some val✝) = Option.map ULift.up none
⊢ some val✝ = none

case hf.some.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝¹ val✝ : τ
hxy : Option.map ULift.up (some val✝¹) = Option.map ULift.up (some val✝)
⊢ some val✝¹ = some val✝
Tactic:
. contradiction
State after:
case hf.some.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝¹ val✝ : τ
hxy : Option.map ULift.up (some val✝¹) = Option.map ULift.up (some val✝)
⊢ some val✝¹ = some val✝

State before:
case hf.some.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝¹ val✝ : τ
hxy : Option.map ULift.up (some val✝¹) = Option.map ULift.up (some val✝)
⊢ some val✝¹ = some val✝
Tactic:
. cases hxy; rfl
State after:
no goals

State before:
case hf.some.none
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝ : τ
hxy : Option.map ULift.up (some val✝) = Option.map ULift.up none
⊢ some val✝ = none
Tactic:
contradiction
State after:
no goals

State before:
case hf.some.some
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝¹ val✝ : τ
hxy : Option.map ULift.up (some val✝¹) = Option.map ULift.up (some val✝)
⊢ some val✝¹ = some val✝
Tactic:
cases hxy
State after:
case hf.some.some.refl
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝ : τ
⊢ some val✝ = some val✝

State before:
case hf.some.some.refl
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
val✝ : τ
⊢ some val✝ = some val✝
Tactic:
rfl
State after:
no goals

State before:
case hxs
η : Type u_η
dec_η : DecidableEq η
sch : Schema
τ : Type u_1
inst : DecidableEq τ
t : Table sch
c : η
hc : Schema.HasCol (c, τ) sch
⊢ List.NoDuplicates
    (List.map Prod.fst (List.groupByKey (List.map (fun r => (Cell.toOption (Row.getCell r hc), r)) t.rows)))
Tactic:
apply List.groupByKey_fsts_no_duplicates
State after:
no goals