Grace/Cumulus/Set/Function/Quadruples.g17
Imports
Grace.Cumulus.Set.Function.Triples · Grace.Cumulus.Nat.Foundation
Declarations
- membership.four theorem derivation
- pairMap def
- pairMap.function theorem derivation
- pairMap.zero theorem derivation
- pairMap.one theorem derivation
- quadrupleMap def
- quadrupleMap.function theorem derivation
- quadrupleMap.zero theorem derivation
- quadrupleMap.one theorem derivation
- quadrupleMap.two theorem derivation
- quadrupleMap.three theorem derivation
- pointMap def
- pointMap.function theorem derivation
- pointMap.zero theorem derivation
Source
1-- Functions on two and four points: the function on 2 with two given2-- values and the function on 4 with four, as graphs, with their values3-- read off, and the four cases of membership in 4.4-- Part of Cumulus, the Grace17 mathematics library.5-- Copyright (c) 2026 Grant Passmore.6-- Released under the Apache License 2.0. See LICENSE in the repository root.7-- Authors: Grant Passmore89module Grace.Cumulus.Set.Function.Quadruples10import Grace.Cumulus.Set.Function.Triples11import Grace.Cumulus.Nat.Foundation1213-- Membership in 4, by cases.14theorem membership.four (x : Set)15 shows x ∈ 4 ↔ (x = 0 ∨ x = 1 ∨ x = 2 ∨ x = 3)16proof17 have split := membership.successor_set{n := 3} at x18 have three := membership.three at x19 tauto2021-- Functions on two points.2223-- The function on 2 with the values a, b in S.24def pairMap (S a b : Set) : Set :=25 { p ∈ 2 × S | (fst(p) = 0 ∧ snd(p) = a) ∨ (fst(p) = 1 ∧ snd(p) = b) }2627section Pairs28variable (S a b : Set)29hypothesis first : a ∈ S30hypothesis second : b ∈ S3132theorem pairMap.function33 shows pairMap(S, a, b) : 2 → S34proof35 constructor36 . intros p member37 exact member.left38 constructor39 . intros x y relatedY z relatedZ40 obtain ⟨inY, shapeY⟩ := relatedY41 obtain ⟨_, shapeZ⟩ := relatedZ42 obtain ⟨_, i, hi, _, _, pairY⟩ := product.membership.forward with inY43 obtain ⟨xi, rfl⟩ := orderedPair.injective with pairY44 rw xi at shapeY, shapeZ45 have cases := membership.two.forward with hi46 rcases cases with rfl | rfl47 . simp [fst.pair, snd.pair] at shapeY, shapeZ48 cc49 . simp [fst.pair, snd.pair] at shapeY, shapeZ50 cc51 . intros x input52 have cases := membership.two.forward with input53 rcases cases with rfl | rfl54 . refine ⟨a, first, _⟩55 apply pairMap.membership.backward56 refine ⟨(product.pair with input, first), _⟩57 simp [fst.pair, snd.pair]58 . refine ⟨b, second, _⟩59 apply pairMap.membership.backward60 refine ⟨(product.pair with input, second), _⟩61 simp [fst.pair, snd.pair]6263-- The two values, read off the graph.64theorem pairMap.zero65 shows pairMap(S, a, b)(0) = a66proof67 have function := pairMap.function with first, second68 have zero : 0 ∈ 2 by simp [membership.two]69 have atZero : relates(pairMap(S, a, b), 0, a)70 apply pairMap.membership.backward71 refine ⟨(product.pair with zero, first), _⟩72 simp [fst.pair, snd.pair]73 exact FunctionBetween.apply_value with function, zero, atZero7475theorem pairMap.one76 shows pairMap(S, a, b)(1) = b77proof78 have function := pairMap.function with first, second79 have one : 1 ∈ 2 by simp [membership.two]80 have atOne : relates(pairMap(S, a, b), 1, b)81 apply pairMap.membership.backward82 refine ⟨(product.pair with one, second), _⟩83 simp [fst.pair, snd.pair]84 exact FunctionBetween.apply_value with function, one, atOne8586end Pairs8788-- Functions on four points.8990-- The function on 4 with the values a, b, c, d in S.91def quadrupleMap (S a b c d : Set) : Set :=92 { p ∈ 4 × S | (fst(p) = 0 ∧ snd(p) = a) ∨ (fst(p) = 1 ∧ snd(p) = b) ∨93 (fst(p) = 2 ∧ snd(p) = c) ∨ (fst(p) = 3 ∧ snd(p) = d) }9495section Quadruples96variable (S a b c d : Set)97hypothesis first : a ∈ S98hypothesis second : b ∈ S99hypothesis third : c ∈ S100hypothesis fourth : d ∈ S101102theorem quadrupleMap.function103 shows quadrupleMap(S, a, b, c, d) : 4 → S104proof105 constructor106 . intros p member107 exact member.left108 constructor109 . intros x y relatedY z relatedZ110 obtain ⟨inY, shapeY⟩ := relatedY111 obtain ⟨_, shapeZ⟩ := relatedZ112 obtain ⟨_, i, hi, _, _, pairY⟩ := product.membership.forward with inY113 obtain ⟨xi, rfl⟩ := orderedPair.injective with pairY114 rw xi at shapeY, shapeZ115 have cases := membership.four.forward with hi116 rcases cases with rfl | rfl | rfl | rfl117 . simp [fst.pair, snd.pair] at shapeY, shapeZ118 cc119 . simp [fst.pair, snd.pair] at shapeY, shapeZ120 cc121 . simp [fst.pair, snd.pair] at shapeY, shapeZ122 cc123 . simp [fst.pair, snd.pair] at shapeY, shapeZ124 cc125 . intros x input126 have cases := membership.four.forward with input127 rcases cases with rfl | rfl | rfl | rfl128 . refine ⟨a, first, _⟩129 apply quadrupleMap.membership.backward130 refine ⟨(product.pair with input, first), _⟩131 simp [fst.pair, snd.pair]132 . refine ⟨b, second, _⟩133 apply quadrupleMap.membership.backward134 refine ⟨(product.pair with input, second), _⟩135 simp [fst.pair, snd.pair]136 . refine ⟨c, third, _⟩137 apply quadrupleMap.membership.backward138 refine ⟨(product.pair with input, third), _⟩139 simp [fst.pair, snd.pair]140 . refine ⟨d, fourth, _⟩141 apply quadrupleMap.membership.backward142 refine ⟨(product.pair with input, fourth), _⟩143 simp [fst.pair, snd.pair]144145-- The four values, read off the graph.146theorem quadrupleMap.zero147 shows quadrupleMap(S, a, b, c, d)(0) = a148proof149 have function := quadrupleMap.function with first, second, third, fourth150 have zero : 0 ∈ 4 by simp [membership.four]151 have atZero : relates(quadrupleMap(S, a, b, c, d), 0, a)152 apply quadrupleMap.membership.backward153 refine ⟨(product.pair with zero, first), _⟩154 simp [fst.pair, snd.pair]155 exact FunctionBetween.apply_value with function, zero, atZero156157theorem quadrupleMap.one158 shows quadrupleMap(S, a, b, c, d)(1) = b159proof160 have function := quadrupleMap.function with first, second, third, fourth161 have one : 1 ∈ 4 by simp [membership.four]162 have atOne : relates(quadrupleMap(S, a, b, c, d), 1, b)163 apply quadrupleMap.membership.backward164 refine ⟨(product.pair with one, second), _⟩165 simp [fst.pair, snd.pair]166 exact FunctionBetween.apply_value with function, one, atOne167168theorem quadrupleMap.two169 shows quadrupleMap(S, a, b, c, d)(2) = c170proof171 have function := quadrupleMap.function with first, second, third, fourth172 have two : 2 ∈ 4 by simp [membership.four]173 have atTwo : relates(quadrupleMap(S, a, b, c, d), 2, c)174 apply quadrupleMap.membership.backward175 refine ⟨(product.pair with two, third), _⟩176 simp [fst.pair, snd.pair]177 exact FunctionBetween.apply_value with function, two, atTwo178179theorem quadrupleMap.three180 shows quadrupleMap(S, a, b, c, d)(3) = d181proof182 have function := quadrupleMap.function with first, second, third, fourth183 have three : 3 ∈ 4 by simp [membership.four]184 have atThree : relates(quadrupleMap(S, a, b, c, d), 3, d)185 apply quadrupleMap.membership.backward186 refine ⟨(product.pair with three, fourth), _⟩187 simp [fst.pair, snd.pair]188 exact FunctionBetween.apply_value with function, three, atThree189190end Quadruples191192-- Functions on one point.193194-- The function on 1 with the value a in S.195def pointMap (S a : Set) : Set := { p ∈ 1 × S | snd(p) = a }196197theorem pointMap.function (S a : Set)198 requires member : a ∈ S199 shows pointMap(S, a) : 1 → S200proof201 constructor202 . intros p inMap203 exact inMap.left204 constructor205 . intros x y relatedY z relatedZ206 obtain ⟨inY, shapeY⟩ := relatedY207 obtain ⟨_, shapeZ⟩ := relatedZ208 obtain ⟨_, i, _, _, _, pairY⟩ := product.membership.forward with inY209 obtain ⟨_, rfl⟩ := orderedPair.injective with pairY210 simp [snd.pair] at shapeY, shapeZ211 cc212 . intros x input213 refine ⟨a, member, _⟩214 apply pointMap.membership.backward215 refine ⟨(product.pair with input, member), _⟩216 simp [snd.pair]217218theorem pointMap.zero (S a : Set)219 requires member : a ∈ S220 shows pointMap(S, a)(0) = a221proof222 have function := pointMap.function with member223 have zero : 0 ∈ 1 by simp [membership.one]224 have atZero : relates(pointMap(S, a), 0, a)225 apply pointMap.membership.backward226 refine ⟨(product.pair with zero, member), _⟩227 simp [snd.pair]228 exact FunctionBetween.apply_value with function, zero, atZero229