:: Introduction to Modal Propositional Logic
:: by Alicia de la Cruz
::
:: Received September 30, 1991
:: Copyright (c) 1991-2021 Association of Mizar Users


Lm1: for m being Nat holds {} is_a_proper_prefix_of <*m*>
by XBOOLE_1:2;

definition
let Z be Tree;
func Root Z -> Element of Z equals :: MODAL_1:def 1
{} ;
coherence
{} is Element of Z
by TREES_1:22;
end;

:: deftheorem defines Root MODAL_1:def 1 :
for Z being Tree holds Root Z = {} ;

definition
let D be non empty set ;
let T be DecoratedTree of D;
func Root T -> Element of D equals :: MODAL_1:def 2
T . (Root (dom T));
coherence
T . (Root (dom T)) is Element of D
;
end;

:: deftheorem defines Root MODAL_1:def 2 :
for D being non empty set
for T being DecoratedTree of D holds Root T = T . (Root (dom T));

theorem Th1: :: MODAL_1:1
for n, m being Nat
for s being FinSequence of NAT st n <> m holds
not <*n*>,<*m*> ^ s are_c=-comparable
proof end;

theorem :: MODAL_1:2
canceled;

::$CT
theorem Th2: :: MODAL_1:3
for n, m being Nat
for s being FinSequence of NAT st n <> m holds
not <*n*> is_a_proper_prefix_of <*m*> ^ s
proof end;

theorem :: MODAL_1:4
canceled;

theorem :: MODAL_1:5
canceled;

theorem :: MODAL_1:6
canceled;

theorem :: MODAL_1:7
canceled;

::$CT 4
theorem Th3: :: MODAL_1:8
for Z being Tree
for n, m being Nat st n <= m & <*m*> in Z holds
<*n*> in Z
proof end;

theorem :: MODAL_1:9
for w, s, t being FinSequence of NAT st w ^ t is_a_proper_prefix_of w ^ s holds
t is_a_proper_prefix_of s by TREES_1:49;

theorem Th5: :: MODAL_1:10
for t1 being DecoratedTree of [:NAT,NAT:] holds t1 in PFuncs ((NAT *),[:NAT,NAT:])
proof end;

theorem Th6: :: MODAL_1:11
for Z, Z1, Z2 being Tree
for z being Element of Z st Z with-replacement (z,Z1) = Z with-replacement (z,Z2) holds
Z1 = Z2
proof end;

theorem Th7: :: MODAL_1:12
for D being non empty set
for Z, Z1, Z2 being DecoratedTree of D
for z being Element of dom Z st Z with-replacement (z,Z1) = Z with-replacement (z,Z2) holds
Z1 = Z2
proof end;

theorem Th8: :: MODAL_1:13
for Z1, Z2 being Tree
for p being FinSequence of NAT st p in Z1 holds
for v being Element of Z1 with-replacement (p,Z2)
for w being Element of Z1 st v = w & w is_a_proper_prefix_of p holds
succ v = succ w
proof end;

theorem Th9: :: MODAL_1:14
for Z1, Z2 being Tree
for p being FinSequence of NAT st p in Z1 holds
for v being Element of Z1 with-replacement (p,Z2)
for w being Element of Z1 st v = w & not p,w are_c=-comparable holds
succ v = succ w
proof end;

theorem :: MODAL_1:15
for Z1, Z2 being Tree
for p being FinSequence of NAT st p in Z1 holds
for v being Element of Z1 with-replacement (p,Z2)
for w being Element of Z2 st v = p ^ w holds
succ v, succ w are_equipotent by TREES_2:37;

theorem Th11: :: MODAL_1:16
for Z1 being Tree
for p being FinSequence of NAT st p in Z1 holds
for v being Element of Z1
for w being Element of Z1 | p st v = p ^ w holds
succ v, succ w are_equipotent
proof end;

theorem Th12: :: MODAL_1:17
for Z being finite Tree st branchdeg (Root Z) = 0 holds
( card Z = 1 & Z = {{}} )
proof end;

theorem Th13: :: MODAL_1:18
for Z being finite Tree st branchdeg (Root Z) = 1 holds
succ (Root Z) = {<*0*>}
proof end;

theorem Th14: :: MODAL_1:19
for Z being finite Tree st branchdeg (Root Z) = 2 holds
succ (Root Z) = {<*0*>,<*1*>}
proof end;

theorem Th15: :: MODAL_1:20
for Z being Tree
for o being Element of Z st o <> Root Z holds
( Z | o, { (o ^ s9) where s9 is Element of NAT * : o ^ s9 in Z } are_equipotent & not Root Z in { (o ^ w9) where w9 is Element of NAT * : o ^ w9 in Z } )
proof end;

theorem Th16: :: MODAL_1:21
for Z being finite Tree
for o being Element of Z st o <> Root Z holds
card (Z | o) < card Z
proof end;

theorem Th17: :: MODAL_1:22
for Z being finite Tree
for z being Element of Z st succ (Root Z) = {z} holds
Z = (elementary_tree 1) with-replacement (<*0*>,(Z | z))
proof end;

Lm2: for f being Function st dom f is finite holds
f is finite

proof end;

theorem Th18: :: MODAL_1:23
for D being non empty set
for Z being finite DecoratedTree of D
for z being Element of dom Z st succ (Root (dom Z)) = {z} holds
Z = ((elementary_tree 1) --> (Root Z)) with-replacement (<*0*>,(Z | z))
proof end;

theorem Th19: :: MODAL_1:24
for Z being Tree
for x1, x2 being Element of Z st x1 = <*0*> & x2 = <*1*> & succ (Root Z) = {x1,x2} holds
Z = ((elementary_tree 2) with-replacement (<*0*>,(Z | x1))) with-replacement (<*1*>,(Z | x2))
proof end;

theorem Th20: :: MODAL_1:25
for D being non empty set
for Z being DecoratedTree of D
for x1, x2 being Element of dom Z st x1 = <*0*> & x2 = <*1*> & succ (Root (dom Z)) = {x1,x2} holds
Z = (((elementary_tree 2) --> (Root Z)) with-replacement (<*0*>,(Z | x1))) with-replacement (<*1*>,(Z | x2))
proof end;

definition
func MP-variables -> set equals :: MODAL_1:def 3
[:{3},NAT:];
coherence
[:{3},NAT:] is set
;
end;

:: deftheorem defines MP-variables MODAL_1:def 3 :
MP-variables = [:{3},NAT:];

registration
cluster MP-variables -> non empty ;
coherence
not MP-variables is empty
;
end;

definition
mode MP-variable is Element of MP-variables ;
end;

definition
func MP-conectives -> set equals :: MODAL_1:def 4
[:{0,1,2},NAT:];
coherence
[:{0,1,2},NAT:] is set
;
end;

:: deftheorem defines MP-conectives MODAL_1:def 4 :
MP-conectives = [:{0,1,2},NAT:];

registration
cluster MP-conectives -> non empty ;
coherence
not MP-conectives is empty
;
end;

definition
mode MP-conective is Element of MP-conectives ;
end;

theorem Th21: :: MODAL_1:26
MP-conectives misses MP-variables
proof end;

definition
let T be finite Tree;
let v be Element of T;
:: original: branchdeg
redefine func branchdeg v -> Nat;
coherence
branchdeg v is Nat
proof end;
end;

definition
func MP-WFF -> DTree-set of [:NAT,NAT:] means :Def5: :: MODAL_1:def 5
( ( for x being DecoratedTree of [:NAT,NAT:] st x in it holds
x is finite ) & ( for x being finite DecoratedTree of [:NAT,NAT:] holds
( x in it iff for v being Element of dom x holds
( branchdeg v <= 2 & ( not branchdeg v = 0 or x . v = [0,0] or ex k being Nat st x . v = [3,k] ) & ( not branchdeg v = 1 or x . v = [1,0] or x . v = [1,1] ) & ( branchdeg v = 2 implies x . v = [2,0] ) ) ) ) );
existence
ex b1 being DTree-set of [:NAT,NAT:] st
( ( for x being DecoratedTree of [:NAT,NAT:] st x in b1 holds
x is finite ) & ( for x being finite DecoratedTree of [:NAT,NAT:] holds
( x in b1 iff for v being Element of dom x holds
( branchdeg v <= 2 & ( not branchdeg v = 0 or x . v = [0,0] or ex k being Nat st x . v = [3,k] ) & ( not branchdeg v = 1 or x . v = [1,0] or x . v = [1,1] ) & ( branchdeg v = 2 implies x . v = [2,0] ) ) ) ) )
proof end;
uniqueness
for b1, b2 being DTree-set of [:NAT,NAT:] st ( for x being DecoratedTree of [:NAT,NAT:] st x in b1 holds
x is finite ) & ( for x being finite DecoratedTree of [:NAT,NAT:] holds
( x in b1 iff for v being Element of dom x holds
( branchdeg v <= 2 & ( not branchdeg v = 0 or x . v = [0,0] or ex k being Nat st x . v = [3,k] ) & ( not branchdeg v = 1 or x . v = [1,0] or x . v = [1,1] ) & ( branchdeg v = 2 implies x . v = [2,0] ) ) ) ) & ( for x being DecoratedTree of [:NAT,NAT:] st x in b2 holds
x is finite ) & ( for x being finite DecoratedTree of [:NAT,NAT:] holds
( x in b2 iff for v being Element of dom x holds
( branchdeg v <= 2 & ( not branchdeg v = 0 or x . v = [0,0] or ex k being Nat st x . v = [3,k] ) & ( not branchdeg v = 1 or x . v = [1,0] or x . v = [1,1] ) & ( branchdeg v = 2 implies x . v = [2,0] ) ) ) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def5 defines MP-WFF MODAL_1:def 5 :
for b1 being DTree-set of [:NAT,NAT:] holds
( b1 = MP-WFF iff ( ( for x being DecoratedTree of [:NAT,NAT:] st x in b1 holds
x is finite ) & ( for x being finite DecoratedTree of [:NAT,NAT:] holds
( x in b1 iff for v being Element of dom x holds
( branchdeg v <= 2 & ( not branchdeg v = 0 or x . v = [0,0] or ex k being Nat st x . v = [3,k] ) & ( not branchdeg v = 1 or x . v = [1,0] or x . v = [1,1] ) & ( branchdeg v = 2 implies x . v = [2,0] ) ) ) ) ) );

:: [0,0] = VERUM
:: [1,0] = negation
:: [1,1] = modal operator of necessity
:: [2,0] = &
definition
mode MP-wff is Element of MP-WFF ;
end;

registration
cluster -> finite for Element of MP-WFF ;
coherence
for b1 being MP-wff holds b1 is finite
by Def5;
end;

definition
let A be MP-wff;
let a be Element of dom A;
:: original: |
redefine func A | a -> MP-wff;
coherence
A | a is MP-wff
proof end;
end;

definition
let a be Element of MP-conectives ;
func the_arity_of a -> Nat equals :: MODAL_1:def 6
a `1 ;
coherence
a `1 is Nat
proof end;
end;

:: deftheorem defines the_arity_of MODAL_1:def 6 :
for a being Element of MP-conectives holds the_arity_of a = a `1 ;

definition
let D be non empty set ;
let T, T1 be DecoratedTree of D;
let p be FinSequence of NAT ;
assume A1: p in dom T ;
func @ (T,p,T1) -> DecoratedTree of D equals :Def7: :: MODAL_1:def 7
T with-replacement (p,T1);
coherence
T with-replacement (p,T1) is DecoratedTree of D
proof end;
end;

:: deftheorem Def7 defines @ MODAL_1:def 7 :
for D being non empty set
for T, T1 being DecoratedTree of D
for p being FinSequence of NAT st p in dom T holds
@ (T,p,T1) = T with-replacement (p,T1);

theorem Th22: :: MODAL_1:27
for A being MP-wff holds ((elementary_tree 1) --> [1,0]) with-replacement (<*0*>,A) is MP-wff
proof end;

theorem Th23: :: MODAL_1:28
for A being MP-wff holds ((elementary_tree 1) --> [1,1]) with-replacement (<*0*>,A) is MP-wff
proof end;

theorem Th24: :: MODAL_1:29
for A, B being MP-wff holds (((elementary_tree 2) --> [2,0]) with-replacement (<*0*>,A)) with-replacement (<*1*>,B) is MP-wff
proof end;

definition
let A be MP-wff;
func 'not' A -> MP-wff equals :: MODAL_1:def 8
((elementary_tree 1) --> [1,0]) with-replacement (<*0*>,A);
coherence
((elementary_tree 1) --> [1,0]) with-replacement (<*0*>,A) is MP-wff
by Th22;
func (#) A -> MP-wff equals :: MODAL_1:def 9
((elementary_tree 1) --> [1,1]) with-replacement (<*0*>,A);
coherence
((elementary_tree 1) --> [1,1]) with-replacement (<*0*>,A) is MP-wff
by Th23;
let B be MP-wff;
func A '&' B -> MP-wff equals :: MODAL_1:def 10
(((elementary_tree 2) --> [2,0]) with-replacement (<*0*>,A)) with-replacement (<*1*>,B);
coherence
(((elementary_tree 2) --> [2,0]) with-replacement (<*0*>,A)) with-replacement (<*1*>,B) is MP-wff
by Th24;
end;

:: deftheorem defines 'not' MODAL_1:def 8 :
for A being MP-wff holds 'not' A = ((elementary_tree 1) --> [1,0]) with-replacement (<*0*>,A);

:: deftheorem defines (#) MODAL_1:def 9 :
for A being MP-wff holds (#) A = ((elementary_tree 1) --> [1,1]) with-replacement (<*0*>,A);

:: deftheorem defines '&' MODAL_1:def 10 :
for A, B being MP-wff holds A '&' B = (((elementary_tree 2) --> [2,0]) with-replacement (<*0*>,A)) with-replacement (<*1*>,B);

definition
let A be MP-wff;
func ? A -> MP-wff equals :: MODAL_1:def 11
'not' ((#) ('not' A));
correctness
coherence
'not' ((#) ('not' A)) is MP-wff
;
;
let B be MP-wff;
func A 'or' B -> MP-wff equals :: MODAL_1:def 12
'not' (('not' A) '&' ('not' B));
correctness
coherence
'not' (('not' A) '&' ('not' B)) is MP-wff
;
;
func A => B -> MP-wff equals :: MODAL_1:def 13
'not' (A '&' ('not' B));
correctness
coherence
'not' (A '&' ('not' B)) is MP-wff
;
;
end;

:: deftheorem defines ? MODAL_1:def 11 :
for A being MP-wff holds ? A = 'not' ((#) ('not' A));

:: deftheorem defines 'or' MODAL_1:def 12 :
for A, B being MP-wff holds A 'or' B = 'not' (('not' A) '&' ('not' B));

:: deftheorem defines => MODAL_1:def 13 :
for A, B being MP-wff holds A => B = 'not' (A '&' ('not' B));

theorem Th25: :: MODAL_1:30
for n being Nat holds (elementary_tree 0) --> [3,n] is MP-wff
proof end;

theorem Th26: :: MODAL_1:31
(elementary_tree 0) --> [0,0] is MP-wff
proof end;

definition
let p be MP-variable;
func @ p -> MP-wff equals :: MODAL_1:def 14
(elementary_tree 0) --> p;
coherence
(elementary_tree 0) --> p is MP-wff
proof end;
end;

:: deftheorem defines @ MODAL_1:def 14 :
for p being MP-variable holds @ p = (elementary_tree 0) --> p;

theorem Th27: :: MODAL_1:32
for p, q being MP-variable st @ p = @ q holds
p = q
proof end;

Lm3: for n, m being Nat holds <*0*> in dom ((elementary_tree 1) --> [n,m])
proof end;

theorem Th28: :: MODAL_1:33
for A, B being MP-wff st 'not' A = 'not' B holds
A = B
proof end;

theorem Th29: :: MODAL_1:34
for A, B being MP-wff st (#) A = (#) B holds
A = B
proof end;

theorem Th30: :: MODAL_1:35
for A, A1, B, B1 being MP-wff st A '&' B = A1 '&' B1 holds
( A = A1 & B = B1 )
proof end;

definition
func VERUM -> MP-wff equals :: MODAL_1:def 15
(elementary_tree 0) --> [0,0];
coherence
(elementary_tree 0) --> [0,0] is MP-wff
by Th26;
end;

:: deftheorem defines VERUM MODAL_1:def 15 :
VERUM = (elementary_tree 0) --> [0,0];

theorem Th31: :: MODAL_1:36
for A being MP-wff holds
( not card (dom A) = 1 or A = VERUM or ex p being MP-variable st A = @ p )
proof end;

theorem Th32: :: MODAL_1:37
for A being MP-wff holds
( not card (dom A) >= 2 or ex B being MP-wff st
( A = 'not' B or A = (#) B ) or ex B, C being MP-wff st A = B '&' C )
proof end;

theorem Th33: :: MODAL_1:38
for A being MP-wff holds card (dom A) < card (dom ('not' A))
proof end;

theorem Th34: :: MODAL_1:39
for A being MP-wff holds card (dom A) < card (dom ((#) A))
proof end;

theorem Th35: :: MODAL_1:40
for A, B being MP-wff holds
( card (dom A) < card (dom (A '&' B)) & card (dom B) < card (dom (A '&' B)) )
proof end;

definition
let IT be MP-wff;
attr IT is atomic means :Def16: :: MODAL_1:def 16
ex p being MP-variable st IT = @ p;
attr IT is negative means :Def17: :: MODAL_1:def 17
ex A being MP-wff st IT = 'not' A;
attr IT is necessitive means :Def18: :: MODAL_1:def 18
ex A being MP-wff st IT = (#) A;
attr IT is conjunctive means :Def19: :: MODAL_1:def 19
ex A, B being MP-wff st IT = A '&' B;
end;

:: deftheorem Def16 defines atomic MODAL_1:def 16 :
for IT being MP-wff holds
( IT is atomic iff ex p being MP-variable st IT = @ p );

:: deftheorem Def17 defines negative MODAL_1:def 17 :
for IT being MP-wff holds
( IT is negative iff ex A being MP-wff st IT = 'not' A );

:: deftheorem Def18 defines necessitive MODAL_1:def 18 :
for IT being MP-wff holds
( IT is necessitive iff ex A being MP-wff st IT = (#) A );

:: deftheorem Def19 defines conjunctive MODAL_1:def 19 :
for IT being MP-wff holds
( IT is conjunctive iff ex A, B being MP-wff st IT = A '&' B );

registration
cluster Relation-like [:NAT,NAT:] -valued Function-like finite DecoratedTree-like atomic for Element of MP-WFF ;
existence
ex b1 being MP-wff st b1 is atomic
proof end;
cluster Relation-like [:NAT,NAT:] -valued Function-like finite DecoratedTree-like negative for Element of MP-WFF ;
existence
ex b1 being MP-wff st b1 is negative
proof end;
cluster Relation-like [:NAT,NAT:] -valued Function-like finite DecoratedTree-like necessitive for Element of MP-WFF ;
existence
ex b1 being MP-wff st b1 is necessitive
proof end;
cluster Relation-like [:NAT,NAT:] -valued Function-like finite DecoratedTree-like conjunctive for Element of MP-WFF ;
existence
ex b1 being MP-wff st b1 is conjunctive
proof end;
end;

scheme :: MODAL_1:sch 1
MPInd{ P1[ Element of MP-WFF ] } :
for A being Element of MP-WFF holds P1[A]
provided
A1: P1[ VERUM ] and
A2: for p being MP-variable holds P1[ @ p] and
A3: for A being Element of MP-WFF st P1[A] holds
P1[ 'not' A] and
A4: for A being Element of MP-WFF st P1[A] holds
P1[ (#) A] and
A5: for A, B being Element of MP-WFF st P1[A] & P1[B] holds
P1[A '&' B]
proof end;

theorem :: MODAL_1:41
for A being Element of MP-WFF holds
( A = VERUM or A is atomic MP-wff or A is negative MP-wff or A is necessitive MP-wff or A is conjunctive MP-wff )
proof end;

theorem Th37: :: MODAL_1:42
for A being MP-wff holds
( A = VERUM or ex p being MP-variable st A = @ p or ex B being MP-wff st A = 'not' B or ex B being MP-wff st A = (#) B or ex B, C being MP-wff st A = B '&' C )
proof end;

theorem Th38: :: MODAL_1:43
for p being MP-variable
for A, B being MP-wff holds
( @ p <> 'not' A & @ p <> (#) A & @ p <> A '&' B )
proof end;

theorem Th39: :: MODAL_1:44
for A, B, C being MP-wff holds
( 'not' A <> (#) B & 'not' A <> B '&' C )
proof end;

theorem Th40: :: MODAL_1:45
for A, B, C being MP-wff holds (#) A <> B '&' C
proof end;

Lm4: for A, B being MP-wff holds
( VERUM <> 'not' A & VERUM <> (#) A & VERUM <> A '&' B )

proof end;

Lm5: [0,0] is MP-conective
proof end;

Lm6: for p being MP-variable holds VERUM <> @ p
proof end;

theorem :: MODAL_1:46
for p being MP-variable
for A, B being MP-wff holds
( VERUM <> @ p & VERUM <> 'not' A & VERUM <> (#) A & VERUM <> A '&' B ) by Lm4, Lm6;

scheme :: MODAL_1:sch 2
MPFuncEx{ F1() -> non empty set , F2() -> Element of F1(), F3( Element of MP-variables ) -> Element of F1(), F4( Element of F1()) -> Element of F1(), F5( Element of F1()) -> Element of F1(), F6( Element of F1(), Element of F1()) -> Element of F1() } :
ex f being Function of MP-WFF,F1() st
( f . VERUM = F2() & ( for p being MP-variable holds f . (@ p) = F3(p) ) & ( for A being Element of MP-WFF holds f . ('not' A) = F4((f . A)) ) & ( for A being Element of MP-WFF holds f . ((#) A) = F5((f . A)) ) & ( for A, B being Element of MP-WFF holds f . (A '&' B) = F6((f . A),(f . B)) ) )
proof end;