:: Algebra of Normal Forms Is a Heyting Algebra
:: by Andrzej Trybulec
::
:: Copyright (c) 1991-2019 Association of Mizar Users

:: Preliminaries
theorem Th1: :: HEYTING1:1
for A, B, C being non empty set
for f being Function of A,B st ( for x being Element of A holds f . x in C ) holds
f is Function of A,C
proof end;

definition
let A be non empty set ;
let B, C be Element of Fin A;
:: original: c=
redefine pred B c= C means :: HEYTING1:def 1
for a being Element of A st a in B holds
a in C;
compatibility
( B c= C iff for a being Element of A st a in B holds
a in C )
proof end;
end;

:: deftheorem defines c= HEYTING1:def 1 :
for A being non empty set
for B, C being Element of Fin A holds
( B c= C iff for a being Element of A st a in B holds
a in C );

definition
let A be set ;
assume A1: not A is empty ;
func [A] -> non empty set equals :Def2: :: HEYTING1:def 2
A;
correctness
coherence
A is non empty set
;
by A1;
end;

:: deftheorem Def2 defines [ HEYTING1:def 2 :
for A being set st not A is empty holds
[A] = A;

theorem :: HEYTING1:2
for A being set
for B being Element of Fin () st B = {} holds
mi B = {} by ;

Lm1: now :: thesis: for A being set
for a being Element of DISJOINT_PAIRS A holds {a} is Element of Normal_forms_on A
let A be set ; :: thesis: for a being Element of DISJOINT_PAIRS A holds {a} is Element of Normal_forms_on A
let a be Element of DISJOINT_PAIRS A; :: thesis: {a} is Element of Normal_forms_on A
reconsider B = {.a.} as Element of Fin () ;
now :: thesis: for c, b being Element of DISJOINT_PAIRS A st c in B & b in B & c c= b holds
c = b
let c, b be Element of DISJOINT_PAIRS A; :: thesis: ( c in B & b in B & c c= b implies c = b )
assume that
A1: c in B and
A2: b in B and
c c= b ; :: thesis: c = b
c = a by ;
hence c = b by ; :: thesis: verum
end;
hence {a} is Element of Normal_forms_on A by NORMFORM:33; :: thesis: verum
end;

registration
let A be set ;
cluster non empty for Element of Normal_forms_on A;
existence
not for b1 being Element of Normal_forms_on A holds b1 is empty
proof end;
end;

definition
let A be set ;
let a be Element of DISJOINT_PAIRS A;
:: original: {
redefine func {a} -> Element of Normal_forms_on A;
coherence
{a} is Element of Normal_forms_on A
by Lm1;
end;

definition
let A be set ;
let u be Element of ();
func @ u -> Element of Normal_forms_on A equals :: HEYTING1:def 3
u;
coherence
u is Element of Normal_forms_on A
by NORMFORM:def 12;
end;

:: deftheorem defines @ HEYTING1:def 3 :
for A being set
for u being Element of () holds @ u = u;

theorem Th3: :: HEYTING1:3
for A being set
for K being Element of Normal_forms_on A holds mi (K ^ K) = K
proof end;

theorem Th4: :: HEYTING1:4
for A being set
for K being Element of Normal_forms_on A
for X being set st X c= K holds
X in Normal_forms_on A
proof end;

theorem Th5: :: HEYTING1:5
for A being set
for u being Element of ()
for X being set st X c= u holds
X is Element of ()
proof end;

definition
let A be set ;
func Atom A -> Function of (), the carrier of () means :Def4: :: HEYTING1:def 4
for a being Element of DISJOINT_PAIRS A holds it . a = {a};
existence
ex b1 being Function of (), the carrier of () st
for a being Element of DISJOINT_PAIRS A holds b1 . a = {a}
proof end;
uniqueness
for b1, b2 being Function of (), the carrier of () st ( for a being Element of DISJOINT_PAIRS A holds b1 . a = {a} ) & ( for a being Element of DISJOINT_PAIRS A holds b2 . a = {a} ) holds
b1 = b2
proof end;
end;

:: deftheorem Def4 defines Atom HEYTING1:def 4 :
for A being set
for b2 being Function of (), the carrier of () holds
( b2 = Atom A iff for a being Element of DISJOINT_PAIRS A holds b2 . a = {a} );

theorem Th6: :: HEYTING1:6
for A being set
for a, c being Element of DISJOINT_PAIRS A st c in (Atom A) . a holds
c = a
proof end;

theorem Th7: :: HEYTING1:7
for A being set
for a being Element of DISJOINT_PAIRS A holds a in (Atom A) . a
proof end;

theorem :: HEYTING1:8
for A being set
for a being Element of DISJOINT_PAIRS A holds (Atom A) . a = () . a
proof end;

theorem Th9: :: HEYTING1:9
for A being set
for K being Element of Normal_forms_on A holds FinJoin (K,(Atom A)) = FinUnion (K,())
proof end;

theorem Th10: :: HEYTING1:10
for A being set
for u being Element of () holds u = FinJoin ((@ u),(Atom A))
proof end;

Lm2: for A being set
for u, v being Element of () st u [= v holds
for x being Element of [:(Fin A),(Fin A):] st x in u holds
ex b being Element of DISJOINT_PAIRS A st
( b in v & b c= x )

proof end;

Lm3: for A being set
for u, v being Element of () st ( for a being Element of DISJOINT_PAIRS A st a in u holds
ex b being Element of DISJOINT_PAIRS A st
( b in v & b c= a ) ) holds
u [= v

proof end;

definition
let A be set ;
func pair_diff A -> BinOp of [:(Fin A),(Fin A):] means :Def5: :: HEYTING1:def 5
for a, b being Element of [:(Fin A),(Fin A):] holds it . (a,b) = a \ b;
existence
ex b1 being BinOp of [:(Fin A),(Fin A):] st
for a, b being Element of [:(Fin A),(Fin A):] holds b1 . (a,b) = a \ b
proof end;
correctness
uniqueness
for b1, b2 being BinOp of [:(Fin A),(Fin A):] st ( for a, b being Element of [:(Fin A),(Fin A):] holds b1 . (a,b) = a \ b ) & ( for a, b being Element of [:(Fin A),(Fin A):] holds b2 . (a,b) = a \ b ) holds
b1 = b2
;
proof end;
end;

:: deftheorem Def5 defines pair_diff HEYTING1:def 5 :
for A being set
for b2 being BinOp of [:(Fin A),(Fin A):] holds
( b2 = pair_diff A iff for a, b being Element of [:(Fin A),(Fin A):] holds b2 . (a,b) = a \ b );

definition
let A be set ;
let B be Element of Fin ();
func - B -> Element of Fin () equals :: HEYTING1:def 6
() /\ { [ { (g . t1) where t1 is Element of DISJOINT_PAIRS A : ( g . t1 in t1 2 & t1 in B ) } , { (g . t2) where t2 is Element of DISJOINT_PAIRS A : ( g . t2 in t2 1 & t2 in B ) } ] where g is Element of Funcs ((),[A]) : for s being Element of DISJOINT_PAIRS A st s in B holds
g . s in (s 1) \/ (s 2)
}
;
coherence
() /\ { [ { (g . t1) where t1 is Element of DISJOINT_PAIRS A : ( g . t1 in t1 2 & t1 in B ) } , { (g . t2) where t2 is Element of DISJOINT_PAIRS A : ( g . t2 in t2 1 & t2 in B ) } ] where g is Element of Funcs ((),[A]) : for s being Element of DISJOINT_PAIRS A st s in B holds
g . s in (s 1) \/ (s 2)
}
is Element of Fin ()
proof end;
correctness
;
let C be Element of Fin ();
func B =>> C -> Element of Fin () equals :: HEYTING1:def 7
() /\ { (FinPairUnion (B,(() .: (f,())))) where f is Element of Funcs ((),[:(Fin A),(Fin A):]) : f .: B c= C } ;
coherence
() /\ { (FinPairUnion (B,(() .: (f,())))) where f is Element of Funcs ((),[:(Fin A),(Fin A):]) : f .: B c= C } is Element of Fin ()
proof end;
correctness
;
end;

:: deftheorem defines - HEYTING1:def 6 :
for A being set
for B being Element of Fin () holds - B = () /\ { [ { (g . t1) where t1 is Element of DISJOINT_PAIRS A : ( g . t1 in t1 2 & t1 in B ) } , { (g . t2) where t2 is Element of DISJOINT_PAIRS A : ( g . t2 in t2 1 & t2 in B ) } ] where g is Element of Funcs ((),[A]) : for s being Element of DISJOINT_PAIRS A st s in B holds
g . s in (s 1) \/ (s 2)
}
;

:: deftheorem defines =>> HEYTING1:def 7 :
for A being set
for B, C being Element of Fin () holds B =>> C = () /\ { (FinPairUnion (B,(() .: (f,())))) where f is Element of Funcs ((),[:(Fin A),(Fin A):]) : f .: B c= C } ;

theorem Th11: :: HEYTING1:11
for A being set
for B being Element of Fin ()
for c being Element of DISJOINT_PAIRS A st c in - B holds
ex g being Element of Funcs ((),[A]) st
( ( for s being Element of DISJOINT_PAIRS A st s in B holds
g . s in (s 1) \/ (s 2) ) & c = [ { (g . t1) where t1 is Element of DISJOINT_PAIRS A : ( g . t1 in t1 2 & t1 in B ) } , { (g . t2) where t2 is Element of DISJOINT_PAIRS A : ( g . t2 in t2 1 & t2 in B ) } ] )
proof end;

theorem Th12: :: HEYTING1:12
for A being set holds is Element of DISJOINT_PAIRS A
proof end;

theorem Th13: :: HEYTING1:13
for A being set
for K being Element of Normal_forms_on A st K = {} holds
- K =
proof end;

theorem Th14: :: HEYTING1:14
for A being set
for K, L being Element of Normal_forms_on A st K = {} & L = {} holds
K =>> L =
proof end;

theorem Th15: :: HEYTING1:15
for a being Element of DISJOINT_PAIRS {} holds a =
proof end;

theorem Th16: :: HEYTING1:16
proof end;

Lm4:
proof end;

theorem Th17: :: HEYTING1:17
for A being set holds is Element of Normal_forms_on A
proof end;

theorem Th18: :: HEYTING1:18
for A being set
for B, C being Element of Fin ()
for c being Element of DISJOINT_PAIRS A st c in B =>> C holds
ex f being Element of Funcs ((),[:(Fin A),(Fin A):]) st
( f .: B c= C & c = FinPairUnion (B,(() .: (f,()))) )
proof end;

theorem Th19: :: HEYTING1:19
for A being set
for a being Element of DISJOINT_PAIRS A
for K being Element of Normal_forms_on A st K ^ {a} = {} holds
ex b being Element of DISJOINT_PAIRS A st
( b in - K & b c= a )
proof end;

Lm5: now :: thesis: for A being set
for K being Element of Normal_forms_on A
for b being Element of DISJOINT_PAIRS A
for f being Element of Funcs ((),[:(Fin A),(Fin A):]) holds (() .: (f,())) . b = (f . b) \ b
let A be set ; :: thesis: for K being Element of Normal_forms_on A
for b being Element of DISJOINT_PAIRS A
for f being Element of Funcs ((),[:(Fin A),(Fin A):]) holds (() .: (f,())) . b = (f . b) \ b

let K be Element of Normal_forms_on A; :: thesis: for b being Element of DISJOINT_PAIRS A
for f being Element of Funcs ((),[:(Fin A),(Fin A):]) holds (() .: (f,())) . b = (f . b) \ b

let b be Element of DISJOINT_PAIRS A; :: thesis: for f being Element of Funcs ((),[:(Fin A),(Fin A):]) holds (() .: (f,())) . b = (f . b) \ b
let f be Element of Funcs ((),[:(Fin A),(Fin A):]); :: thesis: (() .: (f,())) . b = (f . b) \ b
thus (() .: (f,())) . b = () . ((f . b),(() . b)) by FUNCOP_1:37
.= () . ((f . b),b) by FUNCT_1:18
.= (f . b) \ b by Def5 ; :: thesis: verum
end;

theorem Th20: :: HEYTING1:20
for A being set
for a being Element of DISJOINT_PAIRS A
for u, v being Element of () st ( for c being Element of DISJOINT_PAIRS A st c in u holds
ex b being Element of DISJOINT_PAIRS A st
( b in v & b c= c \/ a ) ) holds
ex b being Element of DISJOINT_PAIRS A st
( b in (@ u) =>> (@ v) & b c= a )
proof end;

Lm6: for A being set
for a being Element of DISJOINT_PAIRS A
for u being Element of ()
for K being Element of Normal_forms_on A st a in K ^ (K =>> (@ u)) holds
ex b being Element of DISJOINT_PAIRS A st
( b in u & b c= a )

proof end;

theorem Th21: :: HEYTING1:21
for A being set
for K being Element of Normal_forms_on A holds K ^ (- K) = {}
proof end;

definition
let A be set ;
func pseudo_compl A -> UnOp of the carrier of () means :Def8: :: HEYTING1:def 8
for u being Element of () holds it . u = mi (- (@ u));
existence
ex b1 being UnOp of the carrier of () st
for u being Element of () holds b1 . u = mi (- (@ u))
proof end;
correctness
uniqueness
for b1, b2 being UnOp of the carrier of () st ( for u being Element of () holds b1 . u = mi (- (@ u)) ) & ( for u being Element of () holds b2 . u = mi (- (@ u)) ) holds
b1 = b2
;
proof end;
func StrongImpl A -> BinOp of the carrier of () means :Def9: :: HEYTING1:def 9
for u, v being Element of () holds it . (u,v) = mi ((@ u) =>> (@ v));
existence
ex b1 being BinOp of the carrier of () st
for u, v being Element of () holds b1 . (u,v) = mi ((@ u) =>> (@ v))
proof end;
correctness
uniqueness
for b1, b2 being BinOp of the carrier of () st ( for u, v being Element of () holds b1 . (u,v) = mi ((@ u) =>> (@ v)) ) & ( for u, v being Element of () holds b2 . (u,v) = mi ((@ u) =>> (@ v)) ) holds
b1 = b2
;
proof end;
let u be Element of ();
func SUB u -> Element of Fin the carrier of () equals :: HEYTING1:def 10
bool u;
coherence
bool u is Element of Fin the carrier of ()
proof end;
correctness
;
func diff u -> UnOp of the carrier of () means :Def11: :: HEYTING1:def 11
for v being Element of () holds it . v = u \ v;
existence
ex b1 being UnOp of the carrier of () st
for v being Element of () holds b1 . v = u \ v
proof end;
correctness
uniqueness
for b1, b2 being UnOp of the carrier of () st ( for v being Element of () holds b1 . v = u \ v ) & ( for v being Element of () holds b2 . v = u \ v ) holds
b1 = b2
;
proof end;
end;

:: deftheorem Def8 defines pseudo_compl HEYTING1:def 8 :
for A being set
for b2 being UnOp of the carrier of () holds
( b2 = pseudo_compl A iff for u being Element of () holds b2 . u = mi (- (@ u)) );

:: deftheorem Def9 defines StrongImpl HEYTING1:def 9 :
for A being set
for b2 being BinOp of the carrier of () holds
( b2 = StrongImpl A iff for u, v being Element of () holds b2 . (u,v) = mi ((@ u) =>> (@ v)) );

:: deftheorem defines SUB HEYTING1:def 10 :
for A being set
for u being Element of () holds SUB u = bool u;

:: deftheorem Def11 defines diff HEYTING1:def 11 :
for A being set
for u being Element of ()
for b3 being UnOp of the carrier of () holds
( b3 = diff u iff for v being Element of () holds b3 . v = u \ v );

deffunc H1( set ) -> Element of bool [:[: the carrier of (NormForm $1), the carrier of (NormForm$1):], the carrier of (NormForm $1):] = the L_join of (NormForm$1);

deffunc H2( set ) -> Element of bool [:[: the carrier of (NormForm $1), the carrier of (NormForm$1):], the carrier of (NormForm $1):] = the L_meet of (NormForm$1);

Lm7: for A being set
for u, v being Element of () st v in SUB u holds
v "\/" ((diff u) . v) = u

proof end;

theorem Th22: :: HEYTING1:22
for A being set
for u, v being Element of () holds (diff u) . v [= u
proof end;

Lm8: for A being set
for a being Element of DISJOINT_PAIRS A
for u being Element of () ex v being Element of () st
( v in SUB u & (@ v) ^ {a} = {} & ( for b being Element of DISJOINT_PAIRS A st b in (diff u) . v holds
b \/ a in DISJOINT_PAIRS A ) )

proof end;

theorem Th23: :: HEYTING1:23
for A being set
for u being Element of () holds u "/\" (() . u) = Bottom ()
proof end;

theorem Th24: :: HEYTING1:24
for A being set
for u, v being Element of () holds u "/\" (() . (u,v)) [= v
proof end;

theorem Th25: :: HEYTING1:25
for A being set
for a being Element of DISJOINT_PAIRS A
for u being Element of () st (@ u) ^ {a} = {} holds
(Atom A) . a [= () . u
proof end;

theorem Th26: :: HEYTING1:26
for A being set
for a being Element of DISJOINT_PAIRS A
for u, w being Element of () st ( for b being Element of DISJOINT_PAIRS A st b in u holds
b \/ a in DISJOINT_PAIRS A ) & u "/\" ((Atom A) . a) [= w holds
(Atom A) . a [= () . (u,w)
proof end;

Lm9: now :: thesis: for A being set
for u, v being Element of () holds
( u "/\" H3(u,v) [= v & ( for w being Element of () st u "/\" v [= w holds
v [= H3(u,w) ) )
let A be set ; :: thesis: for u, v being Element of () holds
( u "/\" H3(u,v) [= v & ( for w being Element of () st u "/\" v [= w holds
v [= H3(u,w) ) )

let u, v be Element of (); :: thesis: ( u "/\" H3(u,v) [= v & ( for w being Element of () st u "/\" v [= w holds
v [= H3(u,w) ) )

deffunc H3( Element of (), Element of ()) -> Element of the carrier of () = FinJoin ((SUB $1),(H2(A) .: ((),(() [:] ((diff$1),\$2)))));
set Psi = H2(A) .: ((),(() [:] ((diff u),v)));
A1: now :: thesis: for w being Element of () st w in SUB u holds
(H2(A) [;] (u,(H2(A) .: ((),(() [:] ((diff u),v)))))) . w [= v
let w be Element of (); :: thesis: ( w in SUB u implies (H2(A) [;] (u,(H2(A) .: ((),(() [:] ((diff u),v)))))) . w [= v )
set u2 = (diff u) . w;
set pc = () . w;
set si = () . (((diff u) . w),v);
A2: w "/\" ((() . w) "/\" (() . (((diff u) . w),v))) = (w "/\" (() . w)) "/\" (() . (((diff u) . w),v)) by LATTICES:def 7
.= (Bottom ()) "/\" (() . (((diff u) . w),v)) by Th23
.= Bottom () ;
assume w in SUB u ; :: thesis: (H2(A) [;] (u,(H2(A) .: ((),(() [:] ((diff u),v)))))) . w [= v
then A3: w "\/" ((diff u) . w) = u by Lm7;
(H2(A) [;] (u,(H2(A) .: ((),(() [:] ((diff u),v)))))) . w = H2(A) . (u,((H2(A) .: ((),(() [:] ((diff u),v)))) . w)) by FUNCOP_1:53
.= u "/\" ((H2(A) .: ((),(() [:] ((diff u),v)))) . w) by LATTICES:def 2
.= u "/\" (H2(A) . ((() . w),((() [:] ((diff u),v)) . w))) by FUNCOP_1:37
.= u "/\" ((() . w) "/\" ((() [:] ((diff u),v)) . w)) by LATTICES:def 2
.= u "/\" ((() . w) "/\" (() . (((diff u) . w),v))) by FUNCOP_1:48
.= (w "/\" ((() . w) "/\" (() . (((diff u) . w),v)))) "\/" (((diff u) . w) "/\" ((() . w) "/\" (() . (((diff u) . w),v)))) by
.= ((diff u) . w) "/\" ((() . (((diff u) . w),v)) "/\" (() . w)) by A2
.= (((diff u) . w) "/\" (() . (((diff u) . w),v))) "/\" (() . w) by LATTICES:def 7 ;
then A4: (H2(A) [;] (u,(H2(A) .: ((),(() [:] ((diff u),v)))))) . w [= ((diff u) . w) "/\" (() . (((diff u) . w),v)) by LATTICES:6;
((diff u) . w) "/\" (() . (((diff u) . w),v)) [= v by Th24;
hence (H2(A) [;] (u,(H2(A) .: ((),(() [:] ((diff u),v)))))) . w [= v by ; :: thesis: verum
end;
u "/\" H3(u,v) = FinJoin ((SUB u),(H2(A) [;] (u,(H2(A) .: ((),(() [:] ((diff u),v))))))) by LATTICE2:66;
hence u "/\" H3(u,v) [= v by ; :: thesis: for w being Element of () st u "/\" v [= w holds
v [= H3(u,w)

let w be Element of (); :: thesis: ( u "/\" v [= w implies v [= H3(u,w) )
assume A5: u "/\" v [= w ; :: thesis: v [= H3(u,w)
A6: v = FinJoin ((@ v),(Atom A)) by Th10;
then A7: u "/\" v = FinJoin ((@ v),(H2(A) [;] (u,(Atom A)))) by LATTICE2:66;
now :: thesis: for a being Element of DISJOINT_PAIRS A st a in @ v holds
(Atom A) . a [= H3(u,w)
set pf = pseudo_compl A;
set sf = () [:] ((diff u),w);
let a be Element of DISJOINT_PAIRS A; :: thesis: ( a in @ v implies (Atom A) . a [= H3(u,w) )
assume a in @ v ; :: thesis: (Atom A) . a [= H3(u,w)
then (H2(A) [;] (u,(Atom A))) . a [= w by ;
then H2(A) . (u,((Atom A) . a)) [= w by FUNCOP_1:53;
then A8: u "/\" ((Atom A) . a) [= w by LATTICES:def 2;
consider v being Element of () such that
A9: v in SUB u and
A10: (@ v) ^ {a} = {} and
A11: for b being Element of DISJOINT_PAIRS A st b in (diff u) . v holds
b \/ a in DISJOINT_PAIRS A by Lm8;
((diff u) . v) "/\" ((Atom A) . a) [= u "/\" ((Atom A) . a) by ;
then ((diff u) . v) "/\" ((Atom A) . a) [= w by ;
then (Atom A) . a [= () . (((diff u) . v),w) by ;
then A12: (Atom A) . a [= (() [:] ((diff u),w)) . v by FUNCOP_1:48;
A13: (() . v) "/\" ((() [:] ((diff u),w)) . v) = H2(A) . ((() . v),((() [:] ((diff u),w)) . v)) by LATTICES:def 2
.= (H2(A) .: ((),(() [:] ((diff u),w)))) . v by FUNCOP_1:37 ;
(Atom A) . a [= () . v by ;
then (Atom A) . a [= (H2(A) .: ((),(() [:] ((diff u),w)))) . v by ;
hence (Atom A) . a [= H3(u,w) by ; :: thesis: verum
end;
hence v [= H3(u,w) by ; :: thesis: verum
end;

Lm10: for A being set holds NormForm A is implicative
proof end;

registration
let A be set ;
coherence by Lm10;
end;

theorem Th27: :: HEYTING1:27
for A being set
for u, v being Element of () holds u => v = FinJoin ((SUB u),( the L_meet of () .: ((),(() [:] ((diff u),v)))))
proof end;

theorem :: HEYTING1:28
for A being set holds Top () =
proof end;