Theorem: Tree.treesOfNumNodesEq_card_eq_catalan
File: Mathlib/Combinatorics/Enumerative/Catalan.lean

tactic: induction' n using Nat.case_strong_induction_on with n ih
state_before: n : ℕ
⊢ (treesOfNumNodesEq n).card = catalan n
state_after: case hz

⊢ (treesOfNumNodesEq 0).card = catalan 0

case hi
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
⊢ (treesOfNumNodesEq n.succ).card = catalan n.succ

tactic: rw [treesOfNumNodesEq_succ, card_biUnion, catalan_succ']
state_before: case hi
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
⊢ (treesOfNumNodesEq n.succ).card = catalan n.succ
state_after: case hi
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
⊢ ∑ u ∈ antidiagonal n, (pairwiseNode (treesOfNumNodesEq u.1) (treesOfNumNodesEq u.2)).card =
    ∑ ij ∈ antidiagonal n, catalan ij.1 * catalan ij.2

case hi
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
⊢ ∀ x ∈ antidiagonal n,
    ∀ y ∈ antidiagonal n,
      x ≠ y →
        Disjoint (pairwiseNode (treesOfNumNodesEq x.1) (treesOfNumNodesEq x.2))
          (pairwiseNode (treesOfNumNodesEq y.1) (treesOfNumNodesEq y.2))

tactic: simp
state_before: case hz

⊢ (treesOfNumNodesEq 0).card = catalan 0
state_after: no goals

tactic: apply sum_congr rfl
state_before: case hi
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
⊢ ∑ u ∈ antidiagonal n, (pairwiseNode (treesOfNumNodesEq u.1) (treesOfNumNodesEq u.2)).card =
    ∑ ij ∈ antidiagonal n, catalan ij.1 * catalan ij.2
state_after: case hi
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
⊢ ∀ x ∈ antidiagonal n, (pairwiseNode (treesOfNumNodesEq x.1) (treesOfNumNodesEq x.2)).card = catalan x.1 * catalan x.2

tactic: rintro ⟨i, j⟩ H
state_before: case hi
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
⊢ ∀ x ∈ antidiagonal n, (pairwiseNode (treesOfNumNodesEq x.1) (treesOfNumNodesEq x.2)).card = catalan x.1 * catalan x.2
state_after: case hi.mk
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
H : (i, j) ∈ antidiagonal n
⊢ (pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)).card = catalan (i, j).1 * catalan (i, j).2

tactic: rw [card_map, card_product, ih _ (fst_le H), ih _ (snd_le H)]
state_before: case hi.mk
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
H : (i, j) ∈ antidiagonal n
⊢ (pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)).card = catalan (i, j).1 * catalan (i, j).2
state_after: no goals

tactic: simp_rw [disjoint_left]
state_before: case hi
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
⊢ ∀ x ∈ antidiagonal n,
    ∀ y ∈ antidiagonal n,
      x ≠ y →
        Disjoint (pairwiseNode (treesOfNumNodesEq x.1) (treesOfNumNodesEq x.2))
          (pairwiseNode (treesOfNumNodesEq y.1) (treesOfNumNodesEq y.2))
state_after: case hi
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
⊢ ∀ x ∈ antidiagonal n,
    ∀ y ∈ antidiagonal n,
      x ≠ y →
        ∀ ⦃a : Tree Unit⦄,
          a ∈ pairwiseNode (treesOfNumNodesEq x.1) (treesOfNumNodesEq x.2) →
            a ∉ pairwiseNode (treesOfNumNodesEq y.1) (treesOfNumNodesEq y.2)

tactic: rintro ⟨i, j⟩ _ ⟨i', j'⟩ _
state_before: case hi
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
⊢ ∀ x ∈ antidiagonal n,
    ∀ y ∈ antidiagonal n,
      x ≠ y →
        ∀ ⦃a : Tree Unit⦄,
          a ∈ pairwiseNode (treesOfNumNodesEq x.1) (treesOfNumNodesEq x.2) →
            a ∉ pairwiseNode (treesOfNumNodesEq y.1) (treesOfNumNodesEq y.2)
state_after: case hi.mk.mk
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
⊢ (i, j) ≠ (i', j') →
    ∀ ⦃a : Tree Unit⦄,
      a ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2) →
        a ∉ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)

tactic: intros h a
state_before: case hi.mk.mk
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
⊢ (i, j) ≠ (i', j') →
    ∀ ⦃a : Tree Unit⦄,
      a ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2) →
        a ∉ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
state_after: case hi.mk.mk
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Tree Unit
⊢ a ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2) →
    a ∉ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)

tactic: cases' a with a l r
state_before: case hi.mk.mk
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Tree Unit
⊢ a ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2) →
    a ∉ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
state_after: case hi.mk.mk.nil
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
⊢ nil ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2) →
    nil ∉ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)

case hi.mk.mk.node
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
⊢ node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2) →
    node a l r ∉ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)

tactic: intro h
state_before: case hi.mk.mk.nil
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
⊢ nil ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2) →
    nil ∉ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
state_after: case hi.mk.mk.nil
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h✝ : (i, j) ≠ (i', j')
h : nil ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
⊢ nil ∉ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)

tactic: simp at h
state_before: case hi.mk.mk.nil
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h✝ : (i, j) ≠ (i', j')
h : nil ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
⊢ nil ∉ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
state_after: no goals

tactic: intro h1 h2
state_before: case hi.mk.mk.node
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
⊢ node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2) →
    node a l r ∉ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
state_after: case hi.mk.mk.node
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h1 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
h2 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
⊢ False

tactic: apply h
state_before: case hi.mk.mk.node
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h1 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
h2 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
⊢ False
state_after: case hi.mk.mk.node
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h1 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
h2 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
⊢ (i, j) = (i', j')

tactic: trans (numNodes l, numNodes r)
state_before: case hi.mk.mk.node
n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h1 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
h2 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
⊢ (i, j) = (i', j')
state_after: n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h1 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
h2 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
⊢ (i, j) = (l.numNodes, r.numNodes)

n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h1 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
h2 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
⊢ (l.numNodes, r.numNodes) = (i', j')

tactic: simp at h1
state_before: n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h1 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
h2 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
⊢ (i, j) = (l.numNodes, r.numNodes)
state_after: n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h2 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
h1 : l.numNodes = i ∧ r.numNodes = j
⊢ (i, j) = (l.numNodes, r.numNodes)

tactic: simp [h1]
state_before: n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h2 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
h1 : l.numNodes = i ∧ r.numNodes = j
⊢ (i, j) = (l.numNodes, r.numNodes)
state_after: no goals

tactic: simp at h2
state_before: n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h1 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
h2 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i', j').1) (treesOfNumNodesEq (i', j').2)
⊢ (l.numNodes, r.numNodes) = (i', j')
state_after: n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h1 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
h2 : l.numNodes = i' ∧ r.numNodes = j'
⊢ (l.numNodes, r.numNodes) = (i', j')

tactic: simp [h2]
state_before: n : ℕ
ih : ∀ m ≤ n, (treesOfNumNodesEq m).card = catalan m
i j : ℕ
a✝¹ : (i, j) ∈ antidiagonal n
i' j' : ℕ
a✝ : (i', j') ∈ antidiagonal n
h : (i, j) ≠ (i', j')
a : Unit
l r : Tree Unit
h1 : node a l r ∈ pairwiseNode (treesOfNumNodesEq (i, j).1) (treesOfNumNodesEq (i, j).2)
h2 : l.numNodes = i' ∧ r.numNodes = j'
⊢ (l.numNodes, r.numNodes) = (i', j')
state_after: no goals