1-- Functions on three points: the function on 3 with three given values in2-- a set, as a graph, with its values read off.3-- Part of Cumulus, the Grace17 mathematics library.4-- Copyright (c) 2026 Grant Passmore.5-- Released under the Apache License 2.0. See LICENSE in the repository root.6-- Authors: Grant Passmore78module Grace.Cumulus.Set.Function.Triples9import Function10import Tuple1112-- The function on 3 with the values a, b, c in S.13def tripleMap (S a b c : Set) : Set:=14 { p ∈3× S | (fst(p) =0∧ snd(p) = a) ∨15 (fst(p) =1∧ snd(p) = b) ∨ (fst(p) =2∧ snd(p) = c) }1617theorem tripleMap.function (S a b c : Set)18requires first : a ∈ S19requires second : b ∈ S20requires third : c ∈ S21shows tripleMap(S, a, b, c) : 3→ S22proof23constructor24 . intros p member25exact member.left26constructor27 . intros x y relatedY z relatedZ28obtain⟨inY, shapeY⟩:= relatedY29obtain⟨_, shapeZ⟩:= relatedZ30obtain⟨_, i, hi, _, _, pairY⟩:= product.membership.forward with inY31obtain⟨xi, rfl⟩:= orderedPair.injective with pairY32rw xi at shapeY, shapeZ33havecases:= membership.three.forward with hi34have apart01 : 0≠1bysimp35have apart02 : 0≠2bysimp36have apart12 : 1≠2bysimp37have apart10 : 1≠0bysimp38have apart20 : 2≠0bysimp39have apart21 : 2≠1bysimp40rcasescaseswithrfl|rfl|rfl41 . simp [fst.pair, snd.pair, apart01, apart02] at shapeY, shapeZ42cc43 . simp [fst.pair, snd.pair, apart10, apart12] at shapeY, shapeZ44cc45 . simp [fst.pair, snd.pair, apart20, apart21] at shapeY, shapeZ46cc47 . intros x input48havecases:= membership.three.forward with input49rcasescaseswithrfl|rfl|rfl50 . refine⟨a, first, _⟩51apply tripleMap.membership.backward52refine⟨(product.pair with input, first), _⟩53simp [fst.pair, snd.pair]54 . refine⟨b, second, _⟩55apply tripleMap.membership.backward56refine⟨(product.pair with input, second), _⟩57simp [fst.pair, snd.pair]58 . refine⟨c, third, _⟩59apply tripleMap.membership.backward60refine⟨(product.pair with input, third), _⟩61simp [fst.pair, snd.pair]6263theorem tripleMap.value (S a b c : Set)64requires first : a ∈ S65requires second : b ∈ S66requires third : c ∈ S67shows tripleMap(S, a, b, c)(0) = a ∧ tripleMap(S, a, b, c)(1) = b ∧68 tripleMap(S, a, b, c)(2) = c69proof70have function := tripleMap.function with first, second, third71have zero : 0∈3bysimp [membership.three]72have one : 1∈3bysimp [membership.three]73have two : 2∈3bysimp [membership.three]74have atZero : relates(tripleMap(S, a, b, c), 0, a)75apply tripleMap.membership.backward76refine⟨(product.pair with zero, first), _⟩77simp [fst.pair, snd.pair]78have atOne : relates(tripleMap(S, a, b, c), 1, b)79apply tripleMap.membership.backward80refine⟨(product.pair with one, second), _⟩81simp [fst.pair, snd.pair]82have atTwo : relates(tripleMap(S, a, b, c), 2, c)83apply tripleMap.membership.backward84refine⟨(product.pair with two, third), _⟩85simp [fst.pair, snd.pair]86exact⟨(FunctionBetween.apply_value with function, zero, atZero),87 (FunctionBetween.apply_value with function, one, atOne),88 (FunctionBetween.apply_value with function, two, atTwo)⟩89