\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/input vsbasis.input}
\author{Francois Maltey}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
<<*>>=

---
--- april 2008
---

)expose VSBASIS

VFI ==> Vector Fraction Integer
MFI ==> Matrix Fraction Integer
VSB ==> VectorSpaceBasis Fraction Integer

bc3 := canonicalBasis 3 :: List VFI
u : VFI := vector [1,0,-1]
v : VFI := vector [2,1,2]
w : VFI := vector [1,2,1]

-- F = {(x,y,z)|x+y+z=x-y+z=0}
MF : MFI := matrix [[1,1,1],[1,-1,1]]
F := (nullSpace MF)$VSB                            -- a basis is (-1,0,1)
solve (matrix [[2,1,2],[1,2,1]]$MFI, vector [0,0,0])
-- G = vect(v,w)
G := basis [v, w]                               -- this family is a basis
isBasis? [v,w]

-- search (a,b,c) | F = R(a,b,c)
-- (a,b,c) matchs for v and w,
-- so (a,b,c) in the nullSpace of the matrix of lines (2,1,2) and (1,2,1)
RES := nullSpace (transpose horizConcat (v::MFI,w::MFI)) $ VSB
test ((F = RES)$VSB)                                              -- true


-- H = {(x,y,z)|x+2y+z=0}
MH : MFI := matrix [[1,2,1]]

-- a basis of the intersection of G and H
GH := intBasis ([v,w], nullSpace MH)              -- a basis is (-1,1,-1)
GH := intBasis ([[v,w], nullSpace MH])
GH := basis[v,w] * (nullSpace MH)$VSB

-- is u in F
-- transforms the canonical basis in linear expression of vectors u, v and w.
-- this is a decomposition over F+G : F = Ru and G = Rv+Rw
member? (u, F)                                                    -- true
test ((F = basis [u])$VSB)                                        -- true

BE := basis [u,v,w]
coordinates (bc3.1, BE)
coordinates (bc3.2, BE)
coordinates (bc3.3, BE)

-- are F and G complement space :
-- F intersect G = {(0,0,0)} and F + G = R^3
intBasis (F, G)
intBasis [F, G]
F * G
test (((basis [])$VSB = F*G)$VSB)
sumBasis (F, G)
sumBasis ([F, G])
F + G
test ((basis bc3 = BE)$VSB)

-- f(u)=v, f(v)=w and f(w)=u. The matrix of f in basis (u,v,w) is obvious.
-- Changing the basis in order to find the canonical basis of f.

MfBE : MFI := matrix [[0,0,1],[1,0,0],[0,1,0]]
PbcBE := reduce (horizConcat, [u,v,w]::List MFI)
PBEbc := PbcBE^-1
Mfbc := PbcBE * MfBE * PBEbc

-- theses 3 matrices are equal.

reduce (horizConcat, map (v +-> (coordinates(v,BE))::MFI, bc3))
PBEbc
LRES := map (s +-> s.particular::MFI, solve (PbcBE, diagonalMatrix [1,1,1]))
reduce (horizConcat, LRES)

-- f o f o f = id and f^(-1)=f^2

Mfbc^2
Mfbc^3
Mfbc^-1
test (Mfbc^-1 = Mfbc^2)

test (Mfbc * u = v)
test (Mfbc * v = w)
test (Mfbc * w = u)

--
-- verify some subspaces
--

H := nullSpace MH

[subspace? (BE, F), subspace? (basis bc3, F), subspace? (GH, 0$VSB),
 subspace? (GH, F), subspace? (GH, G), subspace? (GH, basis H),
  subspace? (0$VSB, GH), subspace? (F, basis bc3)]

-- [false, false, false, false, true, true, true, true]

--
-- find some complement spaces.
--

C0 := complementSpace (0$VSB, 3)
CGH := complementSpace GH
CF:= complementSpace F
CG := complementSpace G
CH := complementSpace H
CE1 := complementSpace BE
CE2 := complementSpace concat ([u,v,w], bc3)

complementSpace? (B1, B2) ==
  rank intBasis (B1, B2) = 0
    and rank sumBasis (B1, B2) = #concat (B1::List VFI, B2::List VFI).1

-- all the reponses are true.

complementSpace? (C0, 0$VSB)
complementSpace? (0$VSB, C0)
complementSpace? (CGH, GH)
complementSpace? (GH, CGH)
complementSpace? (CF, F)
complementSpace? (F, G)
complementSpace? (CG, G)
complementSpace? (CH, basis H)
complementSpace? (CE1, BE)
complementSpace? (CE2, BE)
not complementSpace? (F, basis H)

@

\end{document}
