:: REWRITE1 semantic presentation

definition
let c1, c2 be FinSequence;
func c1 $^ c2 -> FinSequence means :Def1: :: REWRITE1:def 1
a3 = a1 ^ a2 if ( a1 = {} or a2 = {} )
otherwise ex b1 being Natex b2 being FinSequence st
( len a1 = b1 + 1 & b2 = a1 | (Seg b1) & a3 = b2 ^ a2 );
existence
( ( ( c1 = {} or c2 = {} ) implies ex b1 being FinSequence st b1 = c1 ^ c2 ) & ( c1 = {} or c2 = {} or ex b1 being FinSequenceex b2 being Natex b3 being FinSequence st
( len c1 = b2 + 1 & b3 = c1 | (Seg b2) & b1 = b3 ^ c2 ) ) )
proof end;
uniqueness
for b1, b2 being FinSequence holds
( ( ( c1 = {} or c2 = {} ) & b1 = c1 ^ c2 & b2 = c1 ^ c2 implies b1 = b2 ) & ( c1 = {} or c2 = {} or for b3 being Nat
for b4 being FinSequence holds
( not len c1 = b3 + 1 or not b4 = c1 | (Seg b3) or not b1 = b4 ^ c2 ) or for b3 being Nat
for b4 being FinSequence holds
( not len c1 = b3 + 1 or not b4 = c1 | (Seg b3) or not b2 = b4 ^ c2 ) or b1 = b2 ) )
;
consistency
for b1 being FinSequence holds verum
;
end;

:: deftheorem Def1 defines $^ REWRITE1:def 1 :
for b1, b2, b3 being FinSequence holds
( ( ( b1 = {} or b2 = {} ) implies ( b3 = b1 $^ b2 iff b3 = b1 ^ b2 ) ) & ( b1 = {} or b2 = {} or ( b3 = b1 $^ b2 iff ex b4 being Natex b5 being FinSequence st
( len b1 = b4 + 1 & b5 = b1 | (Seg b4) & b3 = b5 ^ b2 ) ) ) );

E2: now
let c1 be FinSequence;
let c2 be Nat;
assume c2 in dom c1 ;
then c2 in Seg (len c1) by FINSEQ_1:def 3;
hence ( c2 <= len c1 & c2 >= 0 + 1 ) by FINSEQ_1:3;
hence c2 > 0 ;
end;

E3: now
let c1 be FinSequence;
let c2 be Nat;
assume c2 + 1 in dom c1 ;
then c2 + 1 <= len c1 by Lemma2;
hence c2 < len c1 by NAT_1:38;
end;

E4: now
let c1 be FinSequence;
let c2 be Nat;
assume ( ( c2 <= len c1 or c2 < len c1 ) & ( c2 >= 1 or c2 > 0 ) ) ;
then ( c2 <= len c1 & c2 >= 0 + 1 ) by NAT_1:38;
then c2 in Seg (len c1) by FINSEQ_1:3;
hence c2 in dom c1 by FINSEQ_1:def 3;
end;

E5: now
let c1 be FinSequence;
let c2 be Nat;
assume c2 < len c1 ;
then ( c2 + 1 <= len c1 & c2 + 1 >= 1 ) by NAT_1:29, NAT_1:38;
hence c2 + 1 in dom c1 by Lemma4;
end;

theorem Th1: :: REWRITE1:1
for b1 being FinSequence holds
( {} $^ b1 = b1 & b1 $^ {} = b1 )
proof end;

theorem Th2: :: REWRITE1:2
for b1, b2 being FinSequence
for b3 being set st b1 <> {} holds
(b2 ^ <*b3*>) $^ b1 = b2 ^ b1
proof end;

theorem Th3: :: REWRITE1:3
for b1, b2 being FinSequence
for b3, b4 being set holds (b1 ^ <*b3*>) $^ (<*b4*> ^ b2) = (b1 ^ <*b4*>) ^ b2
proof end;

theorem Th4: :: REWRITE1:4
for b1 being FinSequence
for b2 being set st b1 <> {} holds
<*b2*> $^ b1 = b1
proof end;

theorem Th5: :: REWRITE1:5
for b1 being FinSequence st b1 <> {} holds
ex b2 being set ex b3 being FinSequence st
( b1 = <*b2*> ^ b3 & len b1 = (len b3) + 1 )
proof end;

scheme :: REWRITE1:sch 1
s1{ P1[ set , set ], F1() -> FinSequence, F2() -> FinSequence } :
for b1 being Nat st b1 in dom (F1() $^ F2()) & b1 + 1 in dom (F1() $^ F2()) holds
for b2, b3 being set st b2 = (F1() $^ F2()) . b1 & b3 = (F1() $^ F2()) . (b1 + 1) holds
P1[b2,b3]
provided
E7: for b1 being Nat st b1 in dom F1() & b1 + 1 in dom F1() holds
P1[F1() . b1,F1() . (b1 + 1)] and
E8: for b1 being Nat st b1 in dom F2() & b1 + 1 in dom F2() holds
P1[F2() . b1,F2() . (b1 + 1)] and
E9: ( len F1() > 0 & len F2() > 0 & F1() . (len F1()) = F2() . 1 )
proof end;

definition
let c1 be Relation;
mode RedSequence of c1 -> FinSequence means :Def2: :: REWRITE1:def 2
( len a2 > 0 & ( for b1 being Nat st b1 in dom a2 & b1 + 1 in dom a2 holds
[(a2 . b1),(a2 . (b1 + 1))] in a1 ) );
existence
ex b1 being FinSequence st
( len b1 > 0 & ( for b2 being Nat st b2 in dom b1 & b2 + 1 in dom b1 holds
[(b1 . b2),(b1 . (b2 + 1))] in c1 ) )
proof end;
end;

:: deftheorem Def2 defines RedSequence REWRITE1:def 2 :
for b1 being Relation
for b2 being FinSequence holds
( b2 is RedSequence of b1 iff ( len b2 > 0 & ( for b3 being Nat st b3 in dom b2 & b3 + 1 in dom b2 holds
[(b2 . b3),(b2 . (b3 + 1))] in b1 ) ) );

registration
let c1 be Relation;
cluster -> non empty RedSequence of a1;
coherence
for b1 being RedSequence of c1 holds not b1 is empty
proof end;
end;

theorem Th6: :: REWRITE1:6
canceled;

theorem Th7: :: REWRITE1:7
for b1 being Relation
for b2 being set holds <*b2*> is RedSequence of b1
proof end;

theorem Th8: :: REWRITE1:8
for b1 being Relation
for b2, b3 being set st [b2,b3] in b1 holds
<*b2,b3*> is RedSequence of b1
proof end;

theorem Th9: :: REWRITE1:9
for b1 being Relation
for b2, b3 being RedSequence of b1 st b2 . (len b2) = b3 . 1 holds
b2 $^ b3 is RedSequence of b1
proof end;

theorem Th10: :: REWRITE1:10
for b1 being Relation
for b2 being RedSequence of b1 holds Rev b2 is RedSequence of b1 ~
proof end;

theorem Th11: :: REWRITE1:11
for b1, b2 being Relation st b1 c= b2 holds
for b3 being RedSequence of b1 holds b3 is RedSequence of b2
proof end;

definition
let c1 be Relation;
let c2, c3 be set ;
pred c1 reduces c2,c3 means :Def3: :: REWRITE1:def 3
ex b1 being RedSequence of a1 st
( b1 . 1 = a2 & b1 . (len b1) = a3 );
end;

:: deftheorem Def3 defines reduces REWRITE1:def 3 :
for b1 being Relation
for b2, b3 being set holds
( b1 reduces b2,b3 iff ex b4 being RedSequence of b1 st
( b4 . 1 = b2 & b4 . (len b4) = b3 ) );

definition
let c1 be Relation;
let c2, c3 be set ;
pred c2,c3 are_convertible_wrt c1 means :Def4: :: REWRITE1:def 4
a1 \/ (a1 ~ ) reduces a2,a3;
end;

:: deftheorem Def4 defines are_convertible_wrt REWRITE1:def 4 :
for b1 being Relation
for b2, b3 being set holds
( b2,b3 are_convertible_wrt b1 iff b1 \/ (b1 ~ ) reduces b2,b3 );

theorem Th12: :: REWRITE1:12
for b1 being Relation
for b2, b3 being set holds
( b1 reduces b2,b3 iff ex b4 being FinSequence st
( len b4 > 0 & b4 . 1 = b2 & b4 . (len b4) = b3 & ( for b5 being Nat st b5 in dom b4 & b5 + 1 in dom b4 holds
[(b4 . b5),(b4 . (b5 + 1))] in b1 ) ) )
proof end;

theorem Th13: :: REWRITE1:13
for b1 being Relation
for b2 being set holds b1 reduces b2,b2
proof end;

theorem Th14: :: REWRITE1:14
for b1, b2 being set st {} reduces b1,b2 holds
b1 = b2
proof end;

theorem Th15: :: REWRITE1:15
for b1 being Relation
for b2, b3 being set st b1 reduces b2,b3 & not b2 in field b1 holds
b2 = b3
proof end;

theorem Th16: :: REWRITE1:16
for b1 being Relation
for b2, b3 being set st [b2,b3] in b1 holds
b1 reduces b2,b3
proof end;

theorem Th17: :: REWRITE1:17
for b1 being Relation
for b2, b3, b4 being set st b1 reduces b2,b3 & b1 reduces b3,b4 holds
b1 reduces b2,b4
proof end;

theorem Th18: :: REWRITE1:18
for b1 being Relation
for b2 being RedSequence of b1
for b3, b4 being Nat st b3 in dom b2 & b4 in dom b2 & b3 <= b4 holds
b1 reduces b2 . b3,b2 . b4
proof end;

theorem Th19: :: REWRITE1:19
for b1 being Relation
for b2, b3 being set st b1 reduces b2,b3 & b2 <> b3 holds
( b2 in field b1 & b3 in field b1 )
proof end;

theorem Th20: :: REWRITE1:20
for b1 being Relation
for b2, b3 being set st b1 reduces b2,b3 holds
( b2 in field b1 iff b3 in field b1 ) by Th19;

theorem Th21: :: REWRITE1:21
for b1 being Relation
for b2, b3 being set holds
( b1 reduces b2,b3 iff ( b2 = b3 or [b2,b3] in b1 [*] ) )
proof end;

theorem Th22: :: REWRITE1:22
for b1 being Relation
for b2, b3 being set holds
( b1 reduces b2,b3 iff b1 [*] reduces b2,b3 )
proof end;

theorem Th23: :: REWRITE1:23
for b1, b2 being Relation st b1 c= b2 holds
for b3, b4 being set st b1 reduces b3,b4 holds
b2 reduces b3,b4
proof end;

theorem Th24: :: REWRITE1:24
for b1 being Relation
for b2, b3, b4 being set holds
( b1 reduces b3,b4 iff b1 \/ (id b2) reduces b3,b4 )
proof end;

theorem Th25: :: REWRITE1:25
for b1 being Relation
for b2, b3 being set st b1 reduces b2,b3 holds
b1 ~ reduces b3,b2
proof end;

Lemma28: for b1 being Relation
for b2, b3 being set st b2,b3 are_convertible_wrt b1 holds
b3,b2 are_convertible_wrt b1
proof end;

theorem Th26: :: REWRITE1:26
for b1 being Relation
for b2, b3 being set st b1 reduces b2,b3 holds
( b2,b3 are_convertible_wrt b1 & b3,b2 are_convertible_wrt b1 )
proof end;

theorem Th27: :: REWRITE1:27
for b1 being Relation
for b2 being set holds b2,b2 are_convertible_wrt b1
proof end;

theorem Th28: :: REWRITE1:28
for b1, b2 being set st b1,b2 are_convertible_wrt {} holds
b1 = b2
proof end;

theorem Th29: :: REWRITE1:29
for b1 being Relation
for b2, b3 being set st b2,b3 are_convertible_wrt b1 & not b2 in field b1 holds
b2 = b3
proof end;

theorem Th30: :: REWRITE1:30
for b1 being Relation
for b2, b3 being set st [b2,b3] in b1 holds
b2,b3 are_convertible_wrt b1
proof end;

theorem Th31: :: REWRITE1:31
for b1 being Relation
for b2, b3, b4 being set st b2,b3 are_convertible_wrt b1 & b3,b4 are_convertible_wrt b1 holds
b2,b4 are_convertible_wrt b1
proof end;

theorem Th32: :: REWRITE1:32
for b1 being Relation
for b2, b3 being set st b2,b3 are_convertible_wrt b1 holds
b3,b2 are_convertible_wrt b1 by Lemma28;

theorem Th33: :: REWRITE1:33
for b1 being Relation
for b2, b3 being set st b2,b3 are_convertible_wrt b1 & b2 <> b3 holds
( b2 in field b1 & b3 in field b1 )
proof end;

definition
let c1 be Relation;
let c2 be set ;
pred c2 is_a_normal_form_wrt c1 means :: REWRITE1:def 5
for b1 being set holds not [a2,b1] in a1;
end;

:: deftheorem Def5 defines is_a_normal_form_wrt REWRITE1:def 5 :
for b1 being Relation
for b2 being set holds
( b2 is_a_normal_form_wrt b1 iff for b3 being set holds not [b2,b3] in b1 );

theorem Th34: :: REWRITE1:34
for b1 being Relation
for b2, b3 being set st b2 is_a_normal_form_wrt b1 & b1 reduces b2,b3 holds
b2 = b3
proof end;

theorem Th35: :: REWRITE1:35
for b1 being Relation
for b2 being set st not b2 in field b1 holds
b2 is_a_normal_form_wrt b1
proof end;

definition
let c1 be Relation;
let c2, c3 be set ;
pred c3 is_a_normal_form_of c2,c1 means :Def6: :: REWRITE1:def 6
( a3 is_a_normal_form_wrt a1 & a1 reduces a2,a3 );
pred c2,c3 are_convergent_wrt c1 means :Def7: :: REWRITE1:def 7
ex b1 being set st
( a1 reduces a2,b1 & a1 reduces a3,b1 );
pred c2,c3 are_divergent_wrt c1 means :Def8: :: REWRITE1:def 8
ex b1 being set st
( a1 reduces b1,a2 & a1 reduces b1,a3 );
pred c2,c3 are_convergent<=1_wrt c1 means :Def9: :: REWRITE1:def 9
ex b1 being set st
( ( [a2,b1] in a1 or a2 = b1 ) & ( [a3,b1] in a1 or a3 = b1 ) );
pred c2,c3 are_divergent<=1_wrt c1 means :Def10: :: REWRITE1:def 10
ex b1 being set st
( ( [b1,a2] in a1 or a2 = b1 ) & ( [b1,a3] in a1 or a3 = b1 ) );
end;

:: deftheorem Def6 defines is_a_normal_form_of REWRITE1:def 6 :
for b1 being Relation
for b2, b3 being set holds
( b3 is_a_normal_form_of b2,b1 iff ( b3 is_a_normal_form_wrt b1 & b1 reduces b2,b3 ) );

:: deftheorem Def7 defines are_convergent_wrt REWRITE1:def 7 :
for b1 being Relation
for b2, b3 being set holds
( b2,b3 are_convergent_wrt b1 iff ex b4 being set st
( b1 reduces b2,b4 & b1 reduces b3,b4 ) );

:: deftheorem Def8 defines are_divergent_wrt REWRITE1:def 8 :
for b1 being Relation
for b2, b3 being set holds
( b2,b3 are_divergent_wrt b1 iff ex b4 being set st
( b1 reduces b4,b2 & b1 reduces b4,b3 ) );

:: deftheorem Def9 defines are_convergent<=1_wrt REWRITE1:def 9 :
for b1 being Relation
for b2, b3 being set holds
( b2,b3 are_convergent<=1_wrt b1 iff ex b4 being set st
( ( [b2,b4] in b1 or b2 = b4 ) & ( [b3,b4] in b1 or b3 = b4 ) ) );

:: deftheorem Def10 defines are_divergent<=1_wrt REWRITE1:def 10 :
for b1 being Relation
for b2, b3 being set holds
( b2,b3 are_divergent<=1_wrt b1 iff ex b4 being set st
( ( [b4,b2] in b1 or b2 = b4 ) & ( [b4,b3] in b1 or b3 = b4 ) ) );

theorem Th36: :: REWRITE1:36
for b1 being Relation
for b2 being set st not b2 in field b1 holds
b2 is_a_normal_form_of b2,b1
proof end;

theorem Th37: :: REWRITE1:37
for b1 being Relation
for b2, b3 being set st b1 reduces b2,b3 holds
( b2,b3 are_convergent_wrt b1 & b2,b3 are_divergent_wrt b1 & b3,b2 are_convergent_wrt b1 & b3,b2 are_divergent_wrt b1 )
proof end;

theorem Th38: :: REWRITE1:38
for b1 being Relation
for b2, b3 being set st ( b2,b3 are_convergent_wrt b1 or b2,b3 are_divergent_wrt b1 ) holds
b2,b3 are_convertible_wrt b1
proof end;

theorem Th39: :: REWRITE1:39
for b1 being Relation
for b2 being set holds
( b2,b2 are_convergent_wrt b1 & b2,b2 are_divergent_wrt b1 )
proof end;

theorem Th40: :: REWRITE1:40
for b1, b2 being set st ( b1,b2 are_convergent_wrt {} or b1,b2 are_divergent_wrt {} ) holds
b1 = b2
proof end;

theorem Th41: :: REWRITE1:41
for b1 being Relation
for b2, b3 being set st b2,b3 are_convergent_wrt b1 holds
b3,b2 are_convergent_wrt b1
proof end;

theorem Th42: :: REWRITE1:42
for b1 being Relation
for b2, b3 being set st b2,b3 are_divergent_wrt b1 holds
b3,b2 are_divergent_wrt b1
proof end;

theorem Th43: :: REWRITE1:43
for b1 being Relation
for b2, b3, b4 being set st ( ( b1 reduces b2,b3 & b3,b4 are_convergent_wrt b1 ) or ( b2,b3 are_convergent_wrt b1 & b1 reduces b4,b3 ) ) holds
b2,b4 are_convergent_wrt b1
proof end;

theorem Th44: :: REWRITE1:44
for b1 being Relation
for b2, b3, b4 being set st ( ( b1 reduces b3,b2 & b3,b4 are_divergent_wrt b1 ) or ( b2,b3 are_divergent_wrt b1 & b1 reduces b3,b4 ) ) holds
b2,b4 are_divergent_wrt b1
proof end;

theorem Th45: :: REWRITE1:45
for b1 being Relation
for b2, b3 being set st b2,b3 are_convergent<=1_wrt b1 holds
b2,b3 are_convergent_wrt b1
proof end;

theorem Th46: :: REWRITE1:46
for b1 being Relation
for b2, b3 being set st b2,b3 are_divergent<=1_wrt b1 holds
b2,b3 are_divergent_wrt b1
proof end;

definition
let c1 be Relation;
let c2 be set ;
pred c2 has_a_normal_form_wrt c1 means :Def11: :: REWRITE1:def 11
ex b1 being set st b1 is_a_normal_form_of a2,a1;
end;

:: deftheorem Def11 defines has_a_normal_form_wrt REWRITE1:def 11 :
for b1 being Relation
for b2 being set holds
( b2 has_a_normal_form_wrt b1 iff ex b3 being set st b3 is_a_normal_form_of b2,b1 );

theorem Th47: :: REWRITE1:47
for b1 being Relation
for b2 being set st not b2 in field b1 holds
b2 has_a_normal_form_wrt b1
proof end;

definition
let c1 be Relation;
let c2 be set ;
assume that
E52: c2 has_a_normal_form_wrt c1 and
E53: for b1, b2 being set st b1 is_a_normal_form_of c2,c1 & b2 is_a_normal_form_of c2,c1 holds
b1 = b2 ;
func nf c2,c1 -> set means :Def12: :: REWRITE1:def 12
a3 is_a_normal_form_of a2,a1;
existence
ex b1 being set st b1 is_a_normal_form_of c2,c1
by E52, Def11;
uniqueness
for b1, b2 being set st b1 is_a_normal_form_of c2,c1 & b2 is_a_normal_form_of c2,c1 holds
b1 = b2
by E53;
end;

:: deftheorem Def12 defines nf REWRITE1:def 12 :
for b1 being Relation
for b2 being set st b2 has_a_normal_form_wrt b1 & ( for b3, b4 being set st b3 is_a_normal_form_of b2,b1 & b4 is_a_normal_form_of b2,b1 holds
b3 = b4 ) holds
for b3 being set holds
( b3 = nf b2,b1 iff b3 is_a_normal_form_of b2,b1 );

definition
let c1 be Relation;
attr a1 is co-well_founded means :Def13: :: REWRITE1:def 13
a1 ~ is well_founded;
attr a1 is weakly-normalizing means :Def14: :: REWRITE1:def 14
for b1 being set st b1 in field a1 holds
b1 has_a_normal_form_wrt a1;
attr a1 is strongly-normalizing means :: REWRITE1:def 15
for b1 being ManySortedSet of NAT holds
not for b2 being Nat holds [(b1 . b2),(b1 . (b2 + 1))] in a1;
end;

:: deftheorem Def13 defines co-well_founded REWRITE1:def 13 :
for b1 being Relation holds
( b1 is co-well_founded iff b1 ~ is well_founded );

:: deftheorem Def14 defines weakly-normalizing REWRITE1:def 14 :
for b1 being Relation holds
( b1 is weakly-normalizing iff for b2 being set st b2 in field b1 holds
b2 has_a_normal_form_wrt b1 );

:: deftheorem Def15 defines strongly-normalizing REWRITE1:def 15 :
for b1 being Relation holds
( b1 is strongly-normalizing iff for b2 being ManySortedSet of NAT holds
not for b3 being Nat holds [(b2 . b3),(b2 . (b3 + 1))] in b1 );

definition
let c1 be Relation;
redefine attr a1 is co-well_founded means :Def16: :: REWRITE1:def 16
for b1 being set st b1 c= field a1 & b1 <> {} holds
ex b2 being set st
( b2 in b1 & ( for b3 being set st b3 in b1 & b2 <> b3 holds
not [b2,b3] in a1 ) );
compatibility
( c1 is co-well_founded iff for b1 being set st b1 c= field c1 & b1 <> {} holds
ex b2 being set st
( b2 in b1 & ( for b3 being set st b3 in b1 & b2 <> b3 holds
not [b2,b3] in c1 ) ) )
proof end;
end;

:: deftheorem Def16 defines co-well_founded REWRITE1:def 16 :
for b1 being Relation holds
( b1 is co-well_founded iff for b2 being set st b2 c= field b1 & b2 <> {} holds
ex b3 being set st
( b3 in b2 & ( for b4 being set st b4 in b2 & b3 <> b4 holds
not [b3,b4] in b1 ) ) );

scheme :: REWRITE1:sch 2
s2{ F1() -> Relation, P1[ set ] } :
for b1 being set st b1 in field F1() holds
P1[b1]
provided
E56: F1() is co-well_founded and
E57: for b1 being set st ( for b2 being set st [b1,b2] in F1() & b1 <> b2 holds
P1[b2] ) holds
P1[b1]
proof end;

registration
cluster strongly-normalizing -> irreflexive co-well_founded set ;
coherence
for b1 being Relation st b1 is strongly-normalizing holds
( b1 is irreflexive & b1 is co-well_founded )
proof end;
cluster irreflexive co-well_founded -> strongly-normalizing set ;
coherence
for b1 being Relation st b1 is co-well_founded & b1 is irreflexive holds
b1 is strongly-normalizing
proof end;
end;

registration
cluster empty -> irreflexive co-well_founded weakly-normalizing strongly-normalizing set ;
coherence
for b1 being Relation st b1 is empty holds
( b1 is weakly-normalizing & b1 is strongly-normalizing )
proof end;
end;

registration
cluster empty irreflexive co-well_founded weakly-normalizing strongly-normalizing set ;
existence
ex b1 being Relation st b1 is empty
proof end;
end;

theorem Th48: :: REWRITE1:48
for b1 being co-well_founded Relation
for b2 being Relation st b2 c= b1 holds
b2 is co-well_founded
proof end;

registration
cluster strongly-normalizing -> weakly-normalizing set ;
coherence
for b1 being Relation st b1 is strongly-normalizing holds
b1 is weakly-normalizing
proof end;
end;

definition
let c1, c2 be Relation;
pred c1 commutes-weakly_with c2 means :: REWRITE1:def 17
for b1, b2, b3 being set st [b1,b2] in a1 & [b1,b3] in a2 holds
ex b4 being set st
( a2 reduces b2,b4 & a1 reduces b3,b4 );
symmetry
for b1, b2 being Relation st ( for b3, b4, b5 being set st [b3,b4] in b1 & [b3,b5] in b2 holds
ex b6 being set st
( b2 reduces b4,b6 & b1 reduces b5,b6 ) ) holds
for b3, b4, b5 being set st [b3,b4] in b2 & [b3,b5] in b1 holds
ex b6 being set st
( b1 reduces b4,b6 & b2 reduces b5,b6 )
proof end;
pred c1 commutes_with c2 means :Def18: :: REWRITE1:def 18
for b1, b2, b3 being set st a1 reduces b1,b2 & a2 reduces b1,b3 holds
ex b4 being set st
( a2 reduces b2,b4 & a1 reduces b3,b4 );
symmetry
for b1, b2 being Relation st ( for b3, b4, b5 being set st b1 reduces b3,b4 & b2 reduces b3,b5 holds
ex b6 being set st
( b2 reduces b4,b6 & b1 reduces b5,b6 ) ) holds
for b3, b4, b5 being set st b2 reduces b3,b4 & b1 reduces b3,b5 holds
ex b6 being set st
( b1 reduces b4,b6 & b2 reduces b5,b6 )
proof end;
end;

:: deftheorem Def17 defines commutes-weakly_with REWRITE1:def 17 :
for b1, b2 being Relation holds
( b1 commutes-weakly_with b2 iff for b3, b4, b5 being set st [b3,b4] in b1 & [b3,b5] in b2 holds
ex b6 being set st
( b2 reduces b4,b6 & b1 reduces b5,b6 ) );

:: deftheorem Def18 defines commutes_with REWRITE1:def 18 :
for b1, b2 being Relation holds
( b1 commutes_with b2 iff for b3, b4, b5 being set st b1 reduces b3,b4 & b2 reduces b3,b5 holds
ex b6 being set st
( b2 reduces b4,b6 & b1 reduces b5,b6 ) );

theorem Th49: :: REWRITE1:49
for b1, b2 being Relation st b1 commutes_with b2 holds
b1 commutes-weakly_with b2
proof end;

definition
let c1 be Relation;
attr a1 is with_UN_property means :Def19: :: REWRITE1:def 19
for b1, b2 being set st b1 is_a_normal_form_wrt a1 & b2 is_a_normal_form_wrt a1 & b1,b2 are_convertible_wrt a1 holds
b1 = b2;
attr a1 is with_NF_property means :: REWRITE1:def 20
for b1, b2 being set st b1 is_a_normal_form_wrt a1 & b1,b2 are_convertible_wrt a1 holds
a1 reduces b2,b1;
attr a1 is subcommutative means :Def21: :: REWRITE1:def 21
for b1, b2, b3 being set st [b1,b2] in a1 & [b1,b3] in a1 holds
b2,b3 are_convergent<=1_wrt a1;
attr a1 is confluent means :Def22: :: REWRITE1:def 22
for b1, b2 being set st b1,b2 are_divergent_wrt a1 holds
b1,b2 are_convergent_wrt a1;
attr a1 is with_Church-Rosser_property means :Def23: :: REWRITE1:def 23
for b1, b2 being set st b1,b2 are_convertible_wrt a1 holds
b1,b2 are_convergent_wrt a1;
attr a1 is locally-confluent means :Def24: :: REWRITE1:def 24
for b1, b2, b3 being set st [b1,b2] in a1 & [b1,b3] in a1 holds
b2,b3 are_convergent_wrt a1;
end;

:: deftheorem Def19 defines with_UN_property REWRITE1:def 19 :
for b1 being Relation holds
( b1 is with_UN_property iff for b2, b3 being set st b2 is_a_normal_form_wrt b1 & b3 is_a_normal_form_wrt b1 & b2,b3 are_convertible_wrt b1 holds
b2 = b3 );

:: deftheorem Def20 defines with_NF_property REWRITE1:def 20 :
for b1 being Relation holds
( b1 is with_NF_property iff for b2, b3 being set st b2 is_a_normal_form_wrt b1 & b2,b3 are_convertible_wrt b1 holds
b1 reduces b3,b2 );

:: deftheorem Def21 defines subcommutative REWRITE1:def 21 :
for b1 being Relation holds
( b1 is subcommutative iff for b2, b3, b4 being set st [b2,b3] in b1 & [b2,b4] in b1 holds
b3,b4 are_convergent<=1_wrt b1 );

:: deftheorem Def22 defines confluent REWRITE1:def 22 :
for b1 being Relation holds
( b1 is confluent iff for b2, b3 being set st b2,b3 are_divergent_wrt b1 holds
b2,b3 are_convergent_wrt b1 );

:: deftheorem Def23 defines with_Church-Rosser_property REWRITE1:def 23 :
for b1 being Relation holds
( b1 is with_Church-Rosser_property iff for b2, b3 being set st b2,b3 are_convertible_wrt b1 holds
b2,b3 are_convergent_wrt b1 );

:: deftheorem Def24 defines locally-confluent REWRITE1:def 24 :
for b1 being Relation holds
( b1 is locally-confluent iff for b2, b3, b4 being set st [b2,b3] in b1 & [b2,b4] in b1 holds
b3,b4 are_convergent_wrt b1 );

notation
let c1 be Relation;
synonym c1 has_diamond_property for subcommutative c1;
synonym c1 has_Church-Rosser_property for with_Church-Rosser_property c1;
synonym c1 has_weak-Church-Rosser_property for locally-confluent c1;
end;

theorem Th50: :: REWRITE1:50
for b1 being Relation st b1 is subcommutative holds
for b2, b3, b4 being set st b1 reduces b2,b3 & [b2,b4] in b1 holds
b3,b4 are_convergent_wrt b1
proof end;

theorem Th51: :: REWRITE1:51
for b1 being Relation holds
( b1 is confluent iff b1 commutes_with b1 )
proof end;

theorem Th52: :: REWRITE1:52
for b1 being Relation holds
( b1 is confluent iff for b2, b3, b4 being set st b1 reduces b2,b3 & [b2,b4] in b1 holds
b3,b4 are_convergent_wrt b1 )
proof end;

theorem Th53: :: REWRITE1:53
for b1 being Relation holds
( b1 is locally-confluent iff b1 commutes-weakly_with b1 )
proof end;

registration
cluster with_Church-Rosser_property -> confluent set ;
coherence
for b1 being Relation st b1 is with_Church-Rosser_property holds
b1 is confluent
proof end;
cluster confluent -> with_Church-Rosser_property locally-confluent set ;
coherence
for b1 being Relation st b1 is confluent holds
( b1 is locally-confluent & b1 is with_Church-Rosser_property )
proof end;
cluster subcommutative -> confluent set ;
coherence
for b1 being Relation st b1 is subcommutative holds
b1 is confluent
proof end;
cluster with_Church-Rosser_property -> with_NF_property set ;
coherence
for b1 being Relation st b1 is with_Church-Rosser_property holds
b1 is with_NF_property
proof end;
cluster with_NF_property -> with_UN_property set ;
coherence
for b1 being Relation st b1 is with_NF_property holds
b1 is with_UN_property
proof end;
cluster weakly-normalizing with_UN_property -> with_Church-Rosser_property set ;
coherence
for b1 being Relation st b1 is with_UN_property & b1 is weakly-normalizing holds
b1 is with_Church-Rosser_property
proof end;
end;

registration
cluster empty -> with_UN_property with_NF_property subcommutative confluent with_Church-Rosser_property locally-confluent set ;
coherence
for b1 being Relation st b1 is empty holds
b1 is subcommutative
proof end;
end;

registration
cluster empty irreflexive co-well_founded weakly-normalizing strongly-normalizing with_UN_property with_NF_property subcommutative confluent with_Church-Rosser_property locally-confluent set ;
existence
ex b1 being Relation st b1 is empty
proof end;
end;

theorem Th54: :: REWRITE1:54
for b1 being with_UN_property Relation
for b2, b3, b4 being set st b3 is_a_normal_form_of b2,b1 & b4 is_a_normal_form_of b2,b1 holds
b3 = b4
proof end;

theorem Th55: :: REWRITE1:55
for b1 being weakly-normalizing with_UN_property Relation
for b2 being set holds nf b2,b1 is_a_normal_form_of b2,b1
proof end;

theorem Th56: :: REWRITE1:56
for b1 being weakly-normalizing with_UN_property Relation
for b2, b3 being set st b2,b3 are_convertible_wrt b1 holds
nf b2,b1 = nf b3,b1
proof end;

registration
cluster strongly-normalizing locally-confluent -> with_UN_property with_NF_property confluent with_Church-Rosser_property locally-confluent set ;
coherence
for b1 being Relation st b1 is strongly-normalizing & b1 is locally-confluent holds
b1 is confluent
proof end;
end;

definition
let c1 be Relation;
attr a1 is complete means :: REWRITE1:def 25
( a1 is confluent & a1 is strongly-normalizing );
end;

:: deftheorem Def25 defines complete REWRITE1:def 25 :
for b1 being Relation holds
( b1 is complete iff ( b1 is confluent & b1 is strongly-normalizing ) );

registration
cluster complete -> irreflexive co-well_founded weakly-normalizing strongly-normalizing with_UN_property with_NF_property confluent with_Church-Rosser_property locally-confluent set ;
coherence
for b1 being Relation st b1 is complete holds
( b1 is confluent & b1 is strongly-normalizing )
proof end;
cluster strongly-normalizing confluent -> complete set ;
coherence
for b1 being Relation st b1 is confluent & b1 is strongly-normalizing holds
b1 is complete
proof end;
end;

registration
cluster empty irreflexive co-well_founded weakly-normalizing strongly-normalizing with_UN_property with_NF_property subcommutative confluent with_Church-Rosser_property locally-confluent complete set ;
existence
ex b1 being Relation st b1 is empty
proof end;
end;

registration
cluster non empty irreflexive co-well_founded weakly-normalizing strongly-normalizing with_UN_property with_NF_property confluent with_Church-Rosser_property locally-confluent complete set ;
existence
ex b1 being non empty Relation st b1 is complete
proof end;
end;

theorem Th57: :: REWRITE1:57
for b1, b2 being with_Church-Rosser_property Relation st b1 commutes_with b2 holds
b1 \/ b2 has_Church-Rosser_property
proof end;

theorem Th58: :: REWRITE1:58
for b1 being Relation holds
( b1 is confluent iff b1 [*] has_weak-Church-Rosser_property )
proof end;

theorem Th59: :: REWRITE1:59
for b1 being Relation holds
( b1 is confluent iff b1 [*] is subcommutative )
proof end;

definition
let c1, c2 be Relation;
pred c1,c2 are_equivalent means :: REWRITE1:def 26
for b1, b2 being set holds
( b1,b2 are_convertible_wrt a1 iff b1,b2 are_convertible_wrt a2 );
symmetry
for b1, b2 being Relation st ( for b3, b4 being set holds
( b3,b4 are_convertible_wrt b1 iff b3,b4 are_convertible_wrt b2 ) ) holds
for b3, b4 being set holds
( b3,b4 are_convertible_wrt b2 iff b3,b4 are_convertible_wrt b1 )
;
end;

:: deftheorem Def26 defines are_equivalent REWRITE1:def 26 :
for b1, b2 being Relation holds
( b1,b2 are_equivalent iff for b3, b4 being set holds
( b3,b4 are_convertible_wrt b1 iff b3,b4 are_convertible_wrt b2 ) );

definition
let c1 be Relation;
let c2, c3 be set ;
pred c2,c3 are_critical_wrt c1 means :Def27: :: REWRITE1:def 27
( a2,a3 are_divergent<=1_wrt a1 & not a2,a3 are_convergent_wrt a1 );
end;

:: deftheorem Def27 defines are_critical_wrt REWRITE1:def 27 :
for b1 being Relation
for b2, b3 being set holds
( b2,b3 are_critical_wrt b1 iff ( b2,b3 are_divergent<=1_wrt b1 & not b2,b3 are_convergent_wrt b1 ) );

theorem Th60: :: REWRITE1:60
for b1 being Relation
for b2, b3 being set st b2,b3 are_critical_wrt b1 holds
b2,b3 are_convertible_wrt b1
proof end;

theorem Th61: :: REWRITE1:61
for b1 being Relation st ( for b2, b3 being set holds not b2,b3 are_critical_wrt b1 ) holds
b1 is locally-confluent
proof end;

theorem Th62: :: REWRITE1:62
for b1, b2 being Relation st ( for b3, b4 being set st [b3,b4] in b2 holds
b3,b4 are_critical_wrt b1 ) holds
b1,b1 \/ b2 are_equivalent
proof end;

theorem Th63: :: REWRITE1:63
for b1 being Relation ex b2 being complete Relation st
( field b2 c= field b1 & ( for b3, b4 being set holds
( b3,b4 are_convertible_wrt b1 iff b3,b4 are_convergent_wrt b2 ) ) )
proof end;

definition
let c1 be Relation;
mode Completion of c1 -> complete Relation means :Def28: :: REWRITE1:def 28
for b1, b2 being set holds
( b1,b2 are_convertible_wrt a1 iff b1,b2 are_convergent_wrt a2 );
existence
ex b1 being complete Relation st
for b2, b3 being set holds
( b2,b3 are_convertible_wrt c1 iff b2,b3 are_convergent_wrt b1 )
proof end;
end;

:: deftheorem Def28 defines Completion REWRITE1:def 28 :
for b1 being Relation
for b2 being complete Relation holds
( b2 is Completion of b1 iff for b3, b4 being set holds
( b3,b4 are_convertible_wrt b1 iff b3,b4 are_convergent_wrt b2 ) );

theorem Th64: :: REWRITE1:64
for b1 being Relation
for b2 being Completion of b1 holds b1,b2 are_equivalent
proof end;

theorem Th65: :: REWRITE1:65
for b1 being Relation
for b2 being complete Relation st b1,b2 are_equivalent holds
b2 is Completion of b1
proof end;

theorem Th66: :: REWRITE1:66
for b1 being Relation
for b2 being Completion of b1
for b3, b4 being set holds
( b3,b4 are_convertible_wrt b1 iff nf b3,b2 = nf b4,b2 )
proof end;