# HG changeset patch # User soto # Date 1636213876 -32400 # Node ID 339fb67b43755766dd15b2afe14191ee0ab851db # Parent 72667e8198e2b9f7ba3ec0e20e05fccdf0abe955 INIT rbt.agda diff -r 72667e8198e2 -r 339fb67b4375 Paper/escape_agda.rb --- a/Paper/escape_agda.rb Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/escape_agda.rb Sun Nov 07 00:51:16 2021 +0900 @@ -2,7 +2,7 @@ # coding: utf-8 Suffix = '.agda.replaced' -EscapeChar = '@' +EscapeChar = '!' FileName = ARGV.first ReplaceTable = { @@ -18,6 +18,7 @@ 'ℕ' => 'mathbb{N}', '₁' => '_{1}', '₂' => '_{2}', + '₃' => '_{3}', '∎' => 'blacksquare', 'λ' => 'lambda', '∧' => 'wedge', @@ -29,7 +30,8 @@ '∀' => 'forall', '#' => '\#', '⊤' => '\top', - '\'' => '\prime' + '\'' => '\prime', + '≈' => '\approx' } code = File.read(FileName) diff -r 72667e8198e2 -r 339fb67b4375 Paper/soto.pdf Binary file Paper/soto.pdf has changed diff -r 72667e8198e2 -r 339fb67b4375 Paper/soto.tex --- a/Paper/soto.tex Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/soto.tex Sun Nov 07 00:51:16 2021 +0900 @@ -43,7 +43,7 @@ stepnumber=1, numbersep=0.5zw, % lineskip=-0.5ex, - escapechar=\@, + escapechar=\!, } \renewcommand{\lstlistingname}{Code} \usepackage{caption} diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaDebug.agda.replaced --- a/Paper/src/AgdaDebug.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaDebug.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -13,20 +13,20 @@ open SingleLinkedStack open Stack -testStack07 : {m : Level } @$\rightarrow$@ Maybe (Element @$\mathbb{N}$@) -testStack07 = pushSingleLinkedStack emptySingleLinkedStack 1 (\s @$\rightarrow$@ pushSingleLinkedStack s 2 (\s @$\rightarrow$@ top s)) +testStack07 : {m : Level } !$\rightarrow$! Maybe (Element !$\mathbb{N}$!) +testStack07 = pushSingleLinkedStack emptySingleLinkedStack 1 (\s !$\rightarrow$! pushSingleLinkedStack s 2 (\s !$\rightarrow$! top s)) testStack08 = pushSingleLinkedStack emptySingleLinkedStack 1 - $ \s @$\rightarrow$@ pushSingleLinkedStack s 2 - $ \s @$\rightarrow$@ pushSingleLinkedStack s 3 - $ \s @$\rightarrow$@ pushSingleLinkedStack s 4 - $ \s @$\rightarrow$@ pushSingleLinkedStack s 5 - $ \s @$\rightarrow$@ top s + $ \s !$\rightarrow$! pushSingleLinkedStack s 2 + $ \s !$\rightarrow$! pushSingleLinkedStack s 3 + $ \s !$\rightarrow$! pushSingleLinkedStack s 4 + $ \s !$\rightarrow$! pushSingleLinkedStack s 5 + $ \s !$\rightarrow$! top s testStack10 = pushStack emptySingleLinkedStack 1 - $ \s @$\rightarrow$@ pushStack 2 - $ \s @$\rightarrow$@ pushStack 3 - $ \s @$\rightarrow$@ pushStack 4 - $ \s @$\rightarrow$@ pushStack 5 - $ \s @$\rightarrow$@ top s + $ \s !$\rightarrow$! pushStack 2 + $ \s !$\rightarrow$! pushStack 3 + $ \s !$\rightarrow$! pushStack 4 + $ \s !$\rightarrow$! pushStack 5 + $ \s !$\rightarrow$! top s diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaElem.agda.replaced --- a/Paper/src/AgdaElem.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaElem.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ -elem : {A : Set} {{eqA : Eq A}} @$\rightarrow$@ A @$\rightarrow$@ List A @$\rightarrow$@ Bool -elem {{eqA}} x (y @$\text{::}$@ xs) = (Eq._==_ eqA x y) || (elem {{eqA}} x xs) +elem : {A : Set} {{eqA : Eq A}} !$\rightarrow$! A !$\rightarrow$! List A !$\rightarrow$! Bool +elem {{eqA}} x (y !$\text{::}$! xs) = (Eq._==_ eqA x y) || (elem {{eqA}} x xs) elem x [] = false diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaElemApply.agda.replaced --- a/Paper/src/AgdaElemApply.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaElemApply.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ listHas4 : Bool -listHas4 = elem 4 (3 @$\text{::}$@ 2 @$\text{::}$@ 5 @$\text{::}$@ 4 @$\text{::}$@ []) -- true +listHas4 = elem 4 (3 !$\text{::}$! 2 !$\text{::}$! 5 !$\text{::}$! 4 !$\text{::}$! []) -- true diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaFunction.agda.replaced --- a/Paper/src/AgdaFunction.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaFunction.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,2 +1,2 @@ -f : Bool @$\rightarrow$@ Bool +f : Bool !$\rightarrow$! Bool f x = true diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaId.agda.replaced --- a/Paper/src/AgdaId.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaId.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -identity : (A : Set) @$\rightarrow$@ A @$\rightarrow$@ A +identity : (A : Set) !$\rightarrow$! A !$\rightarrow$! A identity A x = x identity-zero : Nat diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaImplicitId.agda.replaced --- a/Paper/src/AgdaImplicitId.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaImplicitId.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,11 +1,11 @@ -id : {A : Set} @$\rightarrow$@ A @$\rightarrow$@ A +id : {A : Set} !$\rightarrow$! A !$\rightarrow$! A id x = x id-zero : Nat id-zero = id zero -id' : {A : Set} @$\rightarrow$@ A @$\rightarrow$@ A -id' {A} x = x +id!$\prime$! : {A : Set} !$\rightarrow$! A !$\rightarrow$! A +id!$\prime$! {A} x = x id-true : Bool id-true = id {Bool} true diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaInstance.agda.replaced --- a/Paper/src/AgdaInstance.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaInstance.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -_==Nat_ : Nat @$\rightarrow$@ Nat @$\rightarrow$@ Bool +_==Nat_ : Nat !$\rightarrow$! Nat !$\rightarrow$! Bool zero ==Nat zero = true (suc n) ==Nat zero = false zero ==Nat (suc m) = false diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaInterface.agda.replaced --- a/Paper/src/AgdaInterface.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaInterface.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,15 +1,15 @@ -record StackMethods {n m : Level } (a : Set n ) {t : Set m }(stackImpl : Set n ) : Set (m Level.@$\sqcup$@ n) where +record StackMethods {n m : Level } (a : Set n ) {t : Set m }(stackImpl : Set n ) : Set (m Level.!$\sqcup$! n) where field - push : stackImpl @$\rightarrow$@ a @$\rightarrow$@ (stackImpl @$\rightarrow$@ t) @$\rightarrow$@ t - pop : stackImpl @$\rightarrow$@ (stackImpl @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t + push : stackImpl !$\rightarrow$! a !$\rightarrow$! (stackImpl !$\rightarrow$! t) !$\rightarrow$! t + pop : stackImpl !$\rightarrow$! (stackImpl !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t open StackMethods -record Stack {n m : Level } (a : Set n ) {t : Set m } (si : Set n ) : Set (m Level.@$\sqcup$@ n) where +record Stack {n m : Level } (a : Set n ) {t : Set m } (si : Set n ) : Set (m Level.!$\sqcup$! n) where field stack : si stackMethods : StackMethods {n} {m} a {t} si - pushStack : a @$\rightarrow$@ (Stack a si @$\rightarrow$@ t) @$\rightarrow$@ t - pushStack d next = push (stackMethods ) (stack ) d (\s1 @$\rightarrow$@ next (record {stack = s1 ; stackMethods = stackMethods } )) - popStack : (Stack a si @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - popStack next = pop (stackMethods ) (stack ) (\s1 d1 @$\rightarrow$@ next (record {stack = s1 ; stackMethods = stackMethods }) d1 ) + pushStack : a !$\rightarrow$! (Stack a si !$\rightarrow$! t) !$\rightarrow$! t + pushStack d next = push (stackMethods ) (stack ) d (\s1 !$\rightarrow$! next (record {stack = s1 ; stackMethods = stackMethods } )) + popStack : (Stack a si !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + popStack next = pop (stackMethods ) (stack ) (\s1 d1 !$\rightarrow$! next (record {stack = s1 ; stackMethods = stackMethods }) d1 ) open Stack diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaLambda.agda.replaced --- a/Paper/src/AgdaLambda.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaLambda.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,5 +1,5 @@ -+1 : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ ++1 : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! +1 n = suc n -- not use lambda -@$\lambda$@+1 : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ -@$\lambda$@+1 = (\n @$\rightarrow$@ suc n) -- use lambda +!$\lambda$!+1 : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! +!$\lambda$!+1 = (\n !$\rightarrow$! suc n) -- use lambda diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaModusPonens.agda.replaced --- a/Paper/src/AgdaModusPonens.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaModusPonens.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,2 +1,2 @@ -f : {A B C : Set} @$\rightarrow$@ ((A @$\rightarrow$@ B) @$\times$@ (B @$\rightarrow$@ C)) @$\rightarrow$@ (A @$\rightarrow$@ C) -f = \p x @$\rightarrow$@ (snd p) ((fst p) x) +f : {A B C : Set} !$\rightarrow$! ((A !$\rightarrow$! B) !$\times$! (B !$\rightarrow$! C)) !$\rightarrow$! (A !$\rightarrow$! C) +f = \p x !$\rightarrow$! (snd p) ((fst p) x) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaNPushNPop.agda.replaced --- a/Paper/src/AgdaNPushNPop.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaNPushNPop.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,13 +1,13 @@ -n-push : {m : Meta} {{_ : M.DataSegment Meta}} (n : @$\mathbb{N}$@) @$\rightarrow$@ M.CodeSegment Meta Meta +n-push : {m : Meta} {{_ : M.DataSegment Meta}} (n : !$\mathbb{N}$!) !$\rightarrow$! M.CodeSegment Meta Meta n-push {{mm}} (zero) = M.cs {{mm}} {{mm}} id -n-push {m} {{mm}} (suc n) = M.cs {{mm}} {{mm}} (\m @$\rightarrow$@ M.exec {{mm}} {{mm}} (n-push {m} {{mm}} n) (pushOnce m)) +n-push {m} {{mm}} (suc n) = M.cs {{mm}} {{mm}} (\m !$\rightarrow$! M.exec {{mm}} {{mm}} (n-push {m} {{mm}} n) (pushOnce m)) -n-pop : {m : Meta} {{_ : M.DataSegment Meta}} (n : @$\mathbb{N}$@) @$\rightarrow$@ M.CodeSegment Meta Meta +n-pop : {m : Meta} {{_ : M.DataSegment Meta}} (n : !$\mathbb{N}$!) !$\rightarrow$! M.CodeSegment Meta Meta n-pop {{mm}} (zero) = M.cs {{mm}} {{mm}} id -n-pop {m} {{mm}} (suc n) = M.cs {{mm}} {{mm}} (\m @$\rightarrow$@ M.exec {{mm}} {{mm}} (n-pop {m} {{mm}} n) (popOnce m)) +n-pop {m} {{mm}} (suc n) = M.cs {{mm}} {{mm}} (\m !$\rightarrow$! M.exec {{mm}} {{mm}} (n-pop {m} {{mm}} n) (popOnce m)) -pop-n-push-type : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ SingleLinkedStack @$\mathbb{N}$@ @$\rightarrow$@ Set@$\_{1}$@ +pop-n-push-type : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! SingleLinkedStack !$\mathbb{N}$! !$\rightarrow$! Set!$\_{1}$! pop-n-push-type n cn ce s = M.exec (M.csComp {meta} (M.cs popOnce) (n-push {meta} (suc n))) meta - @$\equiv$@ M.exec (n-push {meta} n) meta + !$\equiv$! M.exec (n-push {meta} n) meta where meta = id-meta cn ce s diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaNPushNPopProof.agda.replaced --- a/Paper/src/AgdaNPushNPopProof.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaNPushNPopProof.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,58 +1,58 @@ -pop-n-push-type : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ SingleLinkedStack @$\mathbb{N}$@ @$\rightarrow$@ Set@$\_{1}$@ +pop-n-push-type : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! SingleLinkedStack !$\mathbb{N}$! !$\rightarrow$! Set!$\_{1}$! pop-n-push-type n cn ce s = M.exec (M.csComp (M.cs popOnce) (n-push (suc n))) meta - @$\equiv$@ M.exec (n-push n) meta + !$\equiv$! M.exec (n-push n) meta where meta = id-meta cn ce s -pop-n-push : (n cn ce : @$\mathbb{N}$@) @$\rightarrow$@ (s : SingleLinkedStack @$\mathbb{N}$@) @$\rightarrow$@ pop-n-push-type n cn ce s +pop-n-push : (n cn ce : !$\mathbb{N}$!) !$\rightarrow$! (s : SingleLinkedStack !$\mathbb{N}$!) !$\rightarrow$! pop-n-push-type n cn ce s pop-n-push zero cn ce s = refl pop-n-push (suc n) cn ce s = begin M.exec (M.csComp (M.cs popOnce) (n-push (suc (suc n)))) (id-meta cn ce s) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (M.csComp (M.cs popOnce) (M.csComp (n-push (suc n)) (M.cs pushOnce))) (id-meta cn ce s) - @$\equiv$@@$\langle$@ exec-comp (M.cs popOnce) (M.csComp (n-push (suc n)) (M.cs pushOnce)) (id-meta cn ce s) @$\rangle$@ + !$\equiv$!!$\langle$! exec-comp (M.cs popOnce) (M.csComp (n-push (suc n)) (M.cs pushOnce)) (id-meta cn ce s) !$\rangle$! M.exec (M.cs popOnce) (M.exec (M.csComp (n-push (suc n)) (M.cs pushOnce)) (id-meta cn ce s)) - @$\equiv$@@$\langle$@ cong (\x @$\rightarrow$@ M.exec (M.cs popOnce) x) (exec-comp (n-push (suc n)) (M.cs pushOnce) (id-meta cn ce s)) @$\rangle$@ + !$\equiv$!!$\langle$! cong (\x !$\rightarrow$! M.exec (M.cs popOnce) x) (exec-comp (n-push (suc n)) (M.cs pushOnce) (id-meta cn ce s)) !$\rangle$! M.exec (M.cs popOnce) (M.exec (n-push (suc n))(M.exec (M.cs pushOnce) (id-meta cn ce s))) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (M.cs popOnce) (M.exec (n-push (suc n)) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}))) - @$\equiv$@@$\langle$@ sym (exec-comp (M.cs popOnce) (n-push (suc n)) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}))) @$\rangle$@ + !$\equiv$!!$\langle$! sym (exec-comp (M.cs popOnce) (n-push (suc n)) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}))) !$\rangle$! M.exec (M.csComp (M.cs popOnce) (n-push (suc n))) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})) - @$\equiv$@@$\langle$@ pop-n-push n cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}) @$\rangle$@ + !$\equiv$!!$\langle$! pop-n-push n cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}) !$\rangle$! M.exec (n-push n) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (n-push n) (pushOnce (id-meta cn ce s)) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (n-push n) (M.exec (M.cs pushOnce) (id-meta cn ce s)) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (n-push (suc n)) (id-meta cn ce s) - @$\blacksquare$@ + !$\blacksquare$! -n-push-pop-type : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ SingleLinkedStack @$\mathbb{N}$@ @$\rightarrow$@ Set@$\_{1}$@ -n-push-pop-type n cn ce st = M.exec (M.csComp (n-pop n) (n-push n)) meta @$\equiv$@ meta +n-push-pop-type : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! SingleLinkedStack !$\mathbb{N}$! !$\rightarrow$! Set!$\_{1}$! +n-push-pop-type n cn ce st = M.exec (M.csComp (n-pop n) (n-push n)) meta !$\equiv$! meta where meta = id-meta cn ce st -n-push-pop : (n cn ce : @$\mathbb{N}$@) @$\rightarrow$@ (s : SingleLinkedStack @$\mathbb{N}$@) @$\rightarrow$@ n-push-pop-type n cn ce s +n-push-pop : (n cn ce : !$\mathbb{N}$!) !$\rightarrow$! (s : SingleLinkedStack !$\mathbb{N}$!) !$\rightarrow$! n-push-pop-type n cn ce s n-push-pop zero cn ce s = refl n-push-pop (suc n) cn ce s = begin M.exec (M.csComp (n-pop (suc n)) (n-push (suc n))) (id-meta cn ce s) - @$\equiv$@@$\langle$@ refl @$\rangle$@ - M.exec (M.csComp (M.cs (\m @$\rightarrow$@ M.exec (n-pop n) (popOnce m))) (n-push (suc n))) (id-meta cn ce s) - @$\equiv$@@$\langle$@ exec-comp (M.cs (\m @$\rightarrow$@ M.exec (n-pop n) (popOnce m))) (n-push (suc n)) (id-meta cn ce s) @$\rangle$@ - M.exec (M.cs (\m @$\rightarrow$@ M.exec (n-pop n) (popOnce m))) (M.exec (n-push (suc n)) (id-meta cn ce s)) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! + M.exec (M.csComp (M.cs (\m !$\rightarrow$! M.exec (n-pop n) (popOnce m))) (n-push (suc n))) (id-meta cn ce s) + !$\equiv$!!$\langle$! exec-comp (M.cs (\m !$\rightarrow$! M.exec (n-pop n) (popOnce m))) (n-push (suc n)) (id-meta cn ce s) !$\rangle$! + M.exec (M.cs (\m !$\rightarrow$! M.exec (n-pop n) (popOnce m))) (M.exec (n-push (suc n)) (id-meta cn ce s)) + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (n-pop n) (popOnce (M.exec (n-push (suc n)) (id-meta cn ce s))) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (n-pop n) (M.exec (M.cs popOnce) (M.exec (n-push (suc n)) (id-meta cn ce s))) - @$\equiv$@@$\langle$@ cong (\x @$\rightarrow$@ M.exec (n-pop n) x) (sym (exec-comp (M.cs popOnce) (n-push (suc n)) (id-meta cn ce s))) @$\rangle$@ + !$\equiv$!!$\langle$! cong (\x !$\rightarrow$! M.exec (n-pop n) x) (sym (exec-comp (M.cs popOnce) (n-push (suc n)) (id-meta cn ce s))) !$\rangle$! M.exec (n-pop n) (M.exec (M.csComp (M.cs popOnce) (n-push (suc n))) (id-meta cn ce s)) - @$\equiv$@@$\langle$@ cong (\x @$\rightarrow$@ M.exec (n-pop n) x) (pop-n-push n cn ce s) @$\rangle$@ + !$\equiv$!!$\langle$! cong (\x !$\rightarrow$! M.exec (n-pop n) x) (pop-n-push n cn ce s) !$\rangle$! M.exec (n-pop n) (M.exec (n-push n) (id-meta cn ce s)) - @$\equiv$@@$\langle$@ sym (exec-comp (n-pop n) (n-push n) (id-meta cn ce s)) @$\rangle$@ + !$\equiv$!!$\langle$! sym (exec-comp (n-pop n) (n-push n) (id-meta cn ce s)) !$\rangle$! M.exec (M.csComp (n-pop n) (n-push n)) (id-meta cn ce s) - @$\equiv$@@$\langle$@ n-push-pop n cn ce s @$\rangle$@ + !$\equiv$!!$\langle$! n-push-pop n cn ce s !$\rangle$! id-meta cn ce s - @$\blacksquare$@ + !$\blacksquare$! diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaNat.agda.replaced --- a/Paper/src/AgdaNat.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaNat.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ data Nat : Set where zero : Nat - suc : Nat @$\rightarrow$@ Nat + suc : Nat !$\rightarrow$! Nat diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaNot.agda.replaced --- a/Paper/src/AgdaNot.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaNot.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ -not : Bool @$\rightarrow$@ Bool +not : Bool !$\rightarrow$! Bool not true = false not false = true diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaParameterizedModule.agda.replaced --- a/Paper/src/AgdaParameterizedModule.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaParameterizedModule.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,5 +1,5 @@ -module Sort (A : Set) (_<_ : A @$\rightarrow$@ A @$\rightarrow$@ Bool) where -sort : List A @$\rightarrow$@ List A +module Sort (A : Set) (_<_ : A !$\rightarrow$! A !$\rightarrow$! Bool) where +sort : List A !$\rightarrow$! List A sort = -- 実装は省略 ... -- Parameterized Module により N.sort や B.sort が可能 diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaPattern.agda.replaced --- a/Paper/src/AgdaPattern.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaPattern.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ -not : Bool @$\rightarrow$@ Bool +not : Bool !$\rightarrow$! Bool not false = true not x = false diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaPlus.agda.replaced --- a/Paper/src/AgdaPlus.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaPlus.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ -_+_ : Nat @$\rightarrow$@ Nat @$\rightarrow$@ Nat +_+_ : Nat !$\rightarrow$! Nat !$\rightarrow$! Nat zero + m = m suc n + m = suc (n + m) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaProduct.agda.replaced --- a/Paper/src/AgdaProduct.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaProduct.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,8 +1,8 @@ -data _@$\times$@_ (A B : Set) : Set where - <_,_> : A @$\rightarrow$@ B @$\rightarrow$@ A @$\times$@ B +data _!$\times$!_ (A B : Set) : Set where + <_,_> : A !$\rightarrow$! B !$\rightarrow$! A !$\times$! B -fst : {A B : Set} @$\rightarrow$@ A @$\times$@ B @$\rightarrow$@ A +fst : {A B : Set} !$\rightarrow$! A !$\times$! B !$\rightarrow$! A fst < a , _ > = a -snd : {A B : Set} @$\rightarrow$@ A @$\times$@ B @$\rightarrow$@ B +snd : {A B : Set} !$\rightarrow$! A !$\times$! B !$\rightarrow$! B snd < _ , b > = b diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaPushPop.agda.replaced --- a/Paper/src/AgdaPushPop.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaPushPop.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,22 +1,22 @@ -pushSingleLinkedStack : Meta @$\rightarrow$@ Meta +pushSingleLinkedStack : Meta !$\rightarrow$! Meta pushSingleLinkedStack m = M.exec (liftMeta n) (record m {stack = (push s e) }) where n = Meta.nextCS m s = Meta.stack m e = Context.element (Meta.context m) - push : SingleLinkedStack A @$\rightarrow$@ Maybe A @$\rightarrow$@ SingleLinkedStack A + push : SingleLinkedStack A !$\rightarrow$! Maybe A !$\rightarrow$! SingleLinkedStack A push s nothing = s push s (just x) = record {top = just (cons x (top s))} -popSingleLinkedStack : Meta @$\rightarrow$@ Meta +popSingleLinkedStack : Meta !$\rightarrow$! Meta popSingleLinkedStack m = M.exec (liftMeta n) (record m {stack = (st m) ; context = record con {element = (elem m)}}) where n = Meta.nextCS m con = Meta.context m - elem : Meta @$\rightarrow$@ Maybe A + elem : Meta !$\rightarrow$! Maybe A elem record {stack = record { top = (just (cons x _)) }} = just x elem record {stack = record { top = nothing }} = nothing - st : Meta @$\rightarrow$@ SingleLinkedStack A + st : Meta !$\rightarrow$! SingleLinkedStack A st record {stack = record { top = (just (cons _ s)) }} = record {top = s} st record {stack = record { top = nothing }} = record {top = nothing} diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaPushPopProof.agda.replaced --- a/Paper/src/AgdaPushPopProof.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaPushPopProof.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,11 +1,11 @@ -id-meta : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ SingleLinkedStack @$\mathbb{N}$@ @$\rightarrow$@ Meta +id-meta : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! SingleLinkedStack !$\mathbb{N}$! !$\rightarrow$! Meta id-meta n e s = record { context = record {n = n ; element = just e} ; nextCS = (N.cs id) ; stack = s} -push-pop-type : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Element @$\mathbb{N}$@ @$\rightarrow$@ Set@$\_{1}$@ -push-pop-type n e x s = M.exec (M.csComp {meta} (M.cs popOnce) (M.cs pushOnce)) meta @$\equiv$@ meta +push-pop-type : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! Element !$\mathbb{N}$! !$\rightarrow$! Set!$\_{1}$! +push-pop-type n e x s = M.exec (M.csComp {meta} (M.cs popOnce) (M.cs pushOnce)) meta !$\equiv$! meta where meta = id-meta n e record {top = just (cons x (just s))} -push-pop : (n e x : @$\mathbb{N}$@) @$\rightarrow$@ (s : Element @$\mathbb{N}$@) @$\rightarrow$@ push-pop-type n e x s +push-pop : (n e x : !$\mathbb{N}$!) !$\rightarrow$! (s : Element !$\mathbb{N}$!) !$\rightarrow$! push-pop-type n e x s push-pop n e x s = refl diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaRecord.agda.replaced --- a/Paper/src/AgdaRecord.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaRecord.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -3,5 +3,5 @@ x : Nat y : Nat -makePoint : Nat @$\rightarrow$@ Nat @$\rightarrow$@ Point +makePoint : Nat !$\rightarrow$! Nat !$\rightarrow$! Point makePoint a b = record { x = a ; y = b } diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaRecordProj.agda.replaced --- a/Paper/src/AgdaRecordProj.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaRecordProj.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,8 +1,8 @@ -getX : Point @$\rightarrow$@ Nat +getX : Point !$\rightarrow$! Nat getX p = Point.x p -getY : Point @$\rightarrow$@ Nat +getY : Point !$\rightarrow$! Nat getY record { x = a ; y = b} = b -xPlus5 : Point @$\rightarrow$@ Point +xPlus5 : Point !$\rightarrow$! Point xPlus5 p = record p { x = (Point.x p) + 5} diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaSingleLinkedStack.agda.replaced --- a/Paper/src/AgdaSingleLinkedStack.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaSingleLinkedStack.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -singleLinkedStackSpec : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ StackMethods {n} {m} a {t} (SingleLinkedStack a) +singleLinkedStackSpec : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! StackMethods {n} {m} a {t} (SingleLinkedStack a) singleLinkedStackSpec = record { push = pushSingleLinkedStack ; pop = popSingleLinkedStack @@ -8,7 +8,7 @@ ; clear = clearSingleLinkedStack } -createSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ Stack {n} {m} a {t} (SingleLinkedStack a) +createSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! Stack {n} {m} a {t} (SingleLinkedStack a) createSingleLinkedStack = record { stack = emptySingleLinkedStack ; stackMethods = singleLinkedStackSpec @@ -16,14 +16,14 @@ -- Implementation -pushSingleLinkedStack : {n m : Level } {t : Set m } {Data : Set n} @$\rightarrow$@ SingleLinkedStack Data @$\rightarrow$@ Data @$\rightarrow$@ (Code : SingleLinkedStack Data @$\rightarrow$@ t) @$\rightarrow$@ t +pushSingleLinkedStack : {n m : Level } {t : Set m } {Data : Set n} !$\rightarrow$! SingleLinkedStack Data !$\rightarrow$! Data !$\rightarrow$! (Code : SingleLinkedStack Data !$\rightarrow$! t) !$\rightarrow$! t pushSingleLinkedStack stack datum next = next stack1 where element = cons datum (top stack) stack1 = record {top = Just element} -popSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t +popSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t popSingleLinkedStack stack cs with (top stack) ... | Nothing = cs stack Nothing ... | Just d = cs stack1 (Just data1) @@ -31,33 +31,33 @@ data1 = datum d stack1 = record { top = (next d) } -pop2SingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t +pop2SingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t pop2SingleLinkedStack {n} {m} {t} {a} stack cs with (top stack) ... | Nothing = cs stack Nothing Nothing -... | Just d = pop2SingleLinkedStack' {n} {m} stack cs +... | Just d = pop2SingleLinkedStack!$\prime$! {n} {m} stack cs where - pop2SingleLinkedStack' : {n m : Level } {t : Set m } @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t - pop2SingleLinkedStack' stack cs with (next d) + pop2SingleLinkedStack!$\prime$! : {n m : Level } {t : Set m } !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t + pop2SingleLinkedStack!$\prime$! stack cs with (next d) ... | Nothing = cs stack Nothing Nothing ... | Just d1 = cs (record {top = (next d1)}) (Just (datum d)) (Just (datum d1)) -getSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t +getSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t getSingleLinkedStack stack cs with (top stack) ... | Nothing = cs stack Nothing ... | Just d = cs stack (Just data1) where data1 = datum d -get2SingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t +get2SingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t get2SingleLinkedStack {n} {m} {t} {a} stack cs with (top stack) ... | Nothing = cs stack Nothing Nothing -... | Just d = get2SingleLinkedStack' {n} {m} stack cs +... | Just d = get2SingleLinkedStack!$\prime$! {n} {m} stack cs where - get2SingleLinkedStack' : {n m : Level} {t : Set m } @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t - get2SingleLinkedStack' stack cs with (next d) + get2SingleLinkedStack!$\prime$! : {n m : Level} {t : Set m } !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t + get2SingleLinkedStack!$\prime$! stack cs with (next d) ... | Nothing = cs stack Nothing Nothing ... | Just d1 = cs stack (Just (datum d)) (Just (datum d1)) -clearSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (SingleLinkedStack a @$\rightarrow$@ t) @$\rightarrow$@ t +clearSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (SingleLinkedStack a !$\rightarrow$! t) !$\rightarrow$! t clearSingleLinkedStack stack next = next (record {top = Nothing}) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaStack.agda.replaced --- a/Paper/src/AgdaStack.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaStack.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,10 +1,10 @@ data Element (a : Set) : Set where - cons : a @$\rightarrow$@ Maybe (Element a) @$\rightarrow$@ Element a + cons : a !$\rightarrow$! Maybe (Element a) !$\rightarrow$! Element a -datum : {a : Set} @$\rightarrow$@ Element a @$\rightarrow$@ a +datum : {a : Set} !$\rightarrow$! Element a !$\rightarrow$! a datum (cons a _) = a -next : {a : Set} @$\rightarrow$@ Element a @$\rightarrow$@ Maybe (Element a) +next : {a : Set} !$\rightarrow$! Element a !$\rightarrow$! Maybe (Element a) next (cons _ n) = n record SingleLinkedStack (a : Set) : Set where diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaStackDS.agda.replaced --- a/Paper/src/AgdaStackDS.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaStackDS.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -6,7 +6,7 @@ open import subtype Context as N -record Meta : Set@$\_{1}$@ where +record Meta : Set!$\_{1}$! where field -- context as set of data segments context : Context diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaStackImpl.agda.replaced --- a/Paper/src/AgdaStackImpl.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaStackImpl.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -pushSingleLinkedStack : {n m : Level } {t : Set m } {Data : Set n} @$\rightarrow$@ SingleLinkedStack Data @$\rightarrow$@ Data @$\rightarrow$@ (Code : SingleLinkedStack Data @$\rightarrow$@ t) @$\rightarrow$@ t +pushSingleLinkedStack : {n m : Level } {t : Set m } {Data : Set n} !$\rightarrow$! SingleLinkedStack Data !$\rightarrow$! Data !$\rightarrow$! (Code : SingleLinkedStack Data !$\rightarrow$! t) !$\rightarrow$! t pushSingleLinkedStack stack datum next = next stack1 where element = cons datum (top stack) @@ -6,13 +6,13 @@ -- Basic stack implementations are specifications of a Stack -singleLinkedStackSpec : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ StackMethods {n} {m} a {t} (SingleLinkedStack a) +singleLinkedStackSpec : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! StackMethods {n} {m} a {t} (SingleLinkedStack a) singleLinkedStackSpec = record { push = pushSingleLinkedStack ; pop = popSingleLinkedStack } -createSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ Stack {n} {m} a {t} (SingleLinkedStack a) +createSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! Stack {n} {m} a {t} (SingleLinkedStack a) createSingleLinkedStack = record { stack = emptySingleLinkedStack ; tackMethods = singleLinkedStackSpec diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaStackSomeState.agda.replaced --- a/Paper/src/AgdaStackSomeState.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaStackSomeState.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,5 +1,5 @@ -stackInSomeState : {l m : Level} {D : Set l} {t : Set m} (s : SingleLinkedStack D) @$\rightarrow$@ Stack {l} {m} D {t} ( SingleLinkedStack D) +stackInSomeState : {l m : Level} {D : Set l} {t : Set m} (s : SingleLinkedStack D) !$\rightarrow$! Stack {l} {m} D {t} ( SingleLinkedStack D) stackInSomeState s = record { stack = s ; stackMethods = singleLinkedStackSpec } -push@$\rightarrow$@push@$\rightarrow$@pop2 : {l : Level} {D : Set l} (x y : D) (s : SingleLinkedStack D) @$\rightarrow$@ pushStack (stackInSomeState s) x (\s1 @$\rightarrow$@ pushStack s1 y (\s2 @$\rightarrow$@ pop2Stack s2 (\s3 y1 x1 @$\rightarrow$@ (Just x @$\equiv$@ x1) @$\wedge$@ (Just y @$\equiv$@ y1)))) -push@$\rightarrow$@push@$\rightarrow$@pop2 {l} {D} x y s = record {pi1 = refl ; pi2 = refl} +push!$\rightarrow$!push!$\rightarrow$!pop2 : {l : Level} {D : Set l} (x y : D) (s : SingleLinkedStack D) !$\rightarrow$! pushStack (stackInSomeState s) x (\s1 !$\rightarrow$! pushStack s1 y (\s2 !$\rightarrow$! pop2Stack s2 (\s3 y1 x1 !$\rightarrow$! (Just x !$\equiv$! x1) !$\wedge$! (Just y !$\equiv$! y1)))) +push!$\rightarrow$!push!$\rightarrow$!pop2 {l} {D} x y s = record {pi1 = refl ; pi2 = refl} diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaStackTest.agda.replaced --- a/Paper/src/AgdaStackTest.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaStackTest.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,22 +1,22 @@ -- after push 1 and 2, pop2 get 1 and 2 -testStack02 : {m : Level } @$\rightarrow$@ ( Stack @$\mathbb{N}$@ (SingleLinkedStack @$\mathbb{N}$@) @$\rightarrow$@ Bool {m} ) @$\rightarrow$@ Bool {m} -testStack02 cs = pushStack createSingleLinkedStack 1 (\s @$\rightarrow$@ pushStack s 2 cs) +testStack02 : {m : Level } !$\rightarrow$! ( Stack !$\mathbb{N}$! (SingleLinkedStack !$\mathbb{N}$!) !$\rightarrow$! Bool {m} ) !$\rightarrow$! Bool {m} +testStack02 cs = pushStack createSingleLinkedStack 1 (\s !$\rightarrow$! pushStack s 2 cs) -testStack031 : (d1 d2 : @$\mathbb{N}$@ ) @$\rightarrow$@ Bool {Zero} +testStack031 : (d1 d2 : !$\mathbb{N}$! ) !$\rightarrow$! Bool {Zero} testStack031 2 1 = True testStack031 _ _ = False -testStack032 : (d1 d2 : Maybe @$\mathbb{N}$@) @$\rightarrow$@ Bool {Zero} +testStack032 : (d1 d2 : Maybe !$\mathbb{N}$!) !$\rightarrow$! Bool {Zero} testStack032 (Just d1) (Just d2) = testStack031 d1 d2 testStack032 _ _ = False -testStack03 : {m : Level } @$\rightarrow$@ Stack @$\mathbb{N}$@ (SingleLinkedStack @$\mathbb{N}$@) @$\rightarrow$@ ((Maybe @$\mathbb{N}$@) @$\rightarrow$@ (Maybe @$\mathbb{N}$@) @$\rightarrow$@ Bool {m} ) @$\rightarrow$@ Bool {m} -testStack03 s cs = pop2Stack s (\s d1 d2 @$\rightarrow$@ cs d1 d2 ) +testStack03 : {m : Level } !$\rightarrow$! Stack !$\mathbb{N}$! (SingleLinkedStack !$\mathbb{N}$!) !$\rightarrow$! ((Maybe !$\mathbb{N}$!) !$\rightarrow$! (Maybe !$\mathbb{N}$!) !$\rightarrow$! Bool {m} ) !$\rightarrow$! Bool {m} +testStack03 s cs = pop2Stack s (\s d1 d2 !$\rightarrow$! cs d1 d2 ) testStack04 : Bool -testStack04 = testStack02 (\s @$\rightarrow$@ testStack03 s testStack032) +testStack04 = testStack02 (\s !$\rightarrow$! testStack03 s testStack032) -testStack05 : testStack04 @$\equiv$@ True +testStack05 : testStack04 !$\equiv$! True testStack05 = refl diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaTree.agda.replaced --- a/Paper/src/AgdaTree.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaTree.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,22 +1,22 @@ -record TreeMethods {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.@$\sqcup$@ n) where +record TreeMethods {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.!$\sqcup$! n) where field - putImpl : treeImpl @$\rightarrow$@ a @$\rightarrow$@ (treeImpl @$\rightarrow$@ t) @$\rightarrow$@ t - getImpl : treeImpl @$\rightarrow$@ (treeImpl @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t + putImpl : treeImpl !$\rightarrow$! a !$\rightarrow$! (treeImpl !$\rightarrow$! t) !$\rightarrow$! t + getImpl : treeImpl !$\rightarrow$! (treeImpl !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t open TreeMethods -record Tree {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.@$\sqcup$@ n) where +record Tree {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.!$\sqcup$! n) where field tree : treeImpl treeMethods : TreeMethods {n} {m} {a} {t} treeImpl - putTree : a @$\rightarrow$@ (Tree treeImpl @$\rightarrow$@ t) @$\rightarrow$@ t - putTree d next = putImpl (treeMethods ) tree d (\t1 @$\rightarrow$@ next (record {tree = t1 ; treeMethods = treeMethods} )) - getTree : (Tree treeImpl @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - getTree next = getImpl (treeMethods ) tree (\t1 d @$\rightarrow$@ next (record {tree = t1 ; treeMethods = treeMethods} ) d ) + putTree : a !$\rightarrow$! (Tree treeImpl !$\rightarrow$! t) !$\rightarrow$! t + putTree d next = putImpl (treeMethods ) tree d (\t1 !$\rightarrow$! next (record {tree = t1 ; treeMethods = treeMethods} )) + getTree : (Tree treeImpl !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + getTree next = getImpl (treeMethods ) tree (\t1 d !$\rightarrow$! next (record {tree = t1 ; treeMethods = treeMethods} ) d ) open Tree -record RedBlackTree {n m : Level } {t : Set m} (a k : Set n) : Set (m Level.@$\sqcup$@ n) where +record RedBlackTree {n m : Level } {t : Set m} (a k : Set n) : Set (m Level.!$\sqcup$! n) where field root : Maybe (Node a k) nodeStack : SingleLinkedStack (Node a k) - compare : k @$\rightarrow$@ k @$\rightarrow$@ CompareResult {n} + compare : k !$\rightarrow$! k !$\rightarrow$! CompareResult {n} open RedBlackTree diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaTreeDebug.agda.replaced --- a/Paper/src/AgdaTreeDebug.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaTreeDebug.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,9 +1,9 @@ -test31 = putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ ) 1 1 - $ \t @$\rightarrow$@ putTree1 t 2 2 - $ \t @$\rightarrow$@ putTree1 t 3 3 - $ \t @$\rightarrow$@ putTree1 t 4 4 - $ \t @$\rightarrow$@ getRedBlackTree t 4 - $ \t x @$\rightarrow$@ x +test31 = putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$! ) 1 1 + $ \t !$\rightarrow$! putTree1 t 2 2 + $ \t !$\rightarrow$! putTree1 t 3 3 + $ \t !$\rightarrow$! putTree1 t 4 4 + $ \t !$\rightarrow$! getRedBlackTree t 4 + $ \t x !$\rightarrow$! x -- Just -- (record diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaTreeDebugReturnNode4.agda.replaced --- a/Paper/src/AgdaTreeDebugReturnNode4.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaTreeDebugReturnNode4.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,9 +1,9 @@ -test31 = putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ ) 1 1 -$ \t @$\rightarrow$@ putTree1 t 2 2 -$ \t @$\rightarrow$@ putTree1 t 3 3 -$ \t @$\rightarrow$@ putTree1 t 4 4 -$ \t @$\rightarrow$@ getRedBlackTree t 4 -$ \t x @$\rightarrow$@ x +test31 = putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$! ) 1 1 +$ \t !$\rightarrow$! putTree1 t 2 2 +$ \t !$\rightarrow$! putTree1 t 3 3 +$ \t !$\rightarrow$! putTree1 t 4 4 +$ \t !$\rightarrow$! getRedBlackTree t 4 +$ \t x !$\rightarrow$! x -- C-c C-n test31 return -- Just diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaTreeImpl.agda.replaced --- a/Paper/src/AgdaTreeImpl.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaTreeImpl.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,14 +1,14 @@ -record TreeMethods {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.@$\sqcup$@ n) where +record TreeMethods {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.!$\sqcup$! n) where field - putImpl : treeImpl @$\rightarrow$@ a @$\rightarrow$@ (treeImpl @$\rightarrow$@ t) @$\rightarrow$@ t - getImpl : treeImpl @$\rightarrow$@ (treeImpl @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t + putImpl : treeImpl !$\rightarrow$! a !$\rightarrow$! (treeImpl !$\rightarrow$! t) !$\rightarrow$! t + getImpl : treeImpl !$\rightarrow$! (treeImpl !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t -record Tree {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.@$\sqcup$@ n) where +record Tree {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.!$\sqcup$! n) where field tree : treeImpl treeMethods : TreeMethods {n} {m} {a} {t} treeImpl - putTree : a @$\rightarrow$@ (Tree treeImpl @$\rightarrow$@ t) @$\rightarrow$@ t - putTree d next = putImpl (treeMethods ) tree d (\t1 @$\rightarrow$@ next (record {tree = t1 ; treeMethods = treeMethods} )) - getTree : (Tree treeImpl @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - getTree next = getImpl (treeMethods ) tree (\t1 d @$\rightarrow$@ next (record {tree = t1 ; treeMethods = treeMethods} ) d ) + putTree : a !$\rightarrow$! (Tree treeImpl !$\rightarrow$! t) !$\rightarrow$! t + putTree d next = putImpl (treeMethods ) tree d (\t1 !$\rightarrow$! next (record {tree = t1 ; treeMethods = treeMethods} )) + getTree : (Tree treeImpl !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + getTree next = getImpl (treeMethods ) tree (\t1 d !$\rightarrow$! next (record {tree = t1 ; treeMethods = treeMethods} ) d ) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaTreeProof.agda.replaced --- a/Paper/src/AgdaTreeProof.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaTreeProof.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,21 +1,21 @@ -redBlackInSomeState : { m : Level } (a : Set Level.zero) (n : Maybe (Node a @$\mathbb{N}$@)) {t : Set m} @$\rightarrow$@ RedBlackTree {Level.zero} {m} {t} a @$\mathbb{N}$@ +redBlackInSomeState : { m : Level } (a : Set Level.zero) (n : Maybe (Node a !$\mathbb{N}$!)) {t : Set m} !$\rightarrow$! RedBlackTree {Level.zero} {m} {t} a !$\mathbb{N}$! redBlackInSomeState {m} a n {t} = record { root = n ; nodeStack = emptySingleLinkedStack ; compare = compare2 } -putTest1 :{ m : Level } (n : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)) - @$\rightarrow$@ (k : @$\mathbb{N}$@) (x : @$\mathbb{N}$@) - @$\rightarrow$@ putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (redBlackInSomeState {_} @$\mathbb{N}$@ n {Set Level.zero}) k x - (\ t @$\rightarrow$@ getRedBlackTree t k (\ t x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True)) +putTest1 :{ m : Level } (n : Maybe (Node !$\mathbb{N}$! !$\mathbb{N}$!)) + !$\rightarrow$! (k : !$\mathbb{N}$!) (x : !$\mathbb{N}$!) + !$\rightarrow$! putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (redBlackInSomeState {_} !$\mathbb{N}$! n {Set Level.zero}) k x + (\ t !$\rightarrow$! getRedBlackTree t k (\ t x1 !$\rightarrow$! check2 x1 x !$\equiv$! True)) putTest1 n k x with n ... | Just n1 = lemma2 ( record { top = Nothing } ) where - lemma2 : (s : SingleLinkedStack (Node @$\mathbb{N}$@ @$\mathbb{N}$@) ) @$\rightarrow$@ putTree1 (record { root = Just n1 ; nodeStack = s ; compare = compare2 }) k x (@$\lambda$@ t @$\rightarrow$@ - GetRedBlackTree.checkNode t k (@$\lambda$@ t@$\_{1}$@ x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True) (root t)) + lemma2 : (s : SingleLinkedStack (Node !$\mathbb{N}$! !$\mathbb{N}$!) ) !$\rightarrow$! putTree1 (record { root = Just n1 ; nodeStack = s ; compare = compare2 }) k x (!$\lambda$! t !$\rightarrow$! + GetRedBlackTree.checkNode t k (!$\lambda$! t!$\_{1}$! x1 !$\rightarrow$! check2 x1 x !$\equiv$! True) (root t)) lemma2 s with compare2 k (key n1) ... | EQ = lemma3 {!!} where - lemma3 : compare2 k (key n1) @$\equiv$@ EQ @$\rightarrow$@ getRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} {Set Level.zero} ( record { root = Just ( record { + lemma3 : compare2 k (key n1) !$\equiv$! EQ !$\rightarrow$! getRedBlackTree {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} {Set Level.zero} ( record { root = Just ( record { key = key n1 ; value = x ; right = right n1 ; left = left n1 ; color = Black - } ) ; nodeStack = s ; compare = @$\lambda$@ x@$\_{1}$@ y @$\rightarrow$@ compare2 x@$\_{1}$@ y } ) k ( \ t x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True) + } ) ; nodeStack = s ; compare = !$\lambda$! x!$\_{1}$! y !$\rightarrow$! compare2 x!$\_{1}$! y } ) k ( \ t x1 !$\rightarrow$! check2 x1 x !$\equiv$! True) lemma3 eq with compare2 x x | putTest1Lemma2 x ... | EQ | refl with compare2 k (key n1) | eq ... | EQ | refl with compare2 x x | putTest1Lemma2 x @@ -25,10 +25,10 @@ ... | Nothing = lemma1 where - lemma1 : getRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} {Set Level.zero} ( record { root = Just ( record { + lemma1 : getRedBlackTree {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} {Set Level.zero} ( record { root = Just ( record { key = k ; value = x ; right = Nothing ; left = Nothing ; color = Red - } ) ; nodeStack = record { top = Nothing } ; compare = @$\lambda$@ x@$\_{1}$@ y @$\rightarrow$@ compare2 x@$\_{1}$@ y } ) k - ( \ t x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True) + } ) ; nodeStack = record { top = Nothing } ; compare = !$\lambda$! x!$\_{1}$! y !$\rightarrow$! compare2 x!$\_{1}$! y } ) k + ( \ t x1 !$\rightarrow$! check2 x1 x !$\equiv$! True) lemma1 with compare2 k k | putTest1Lemma2 k ... | EQ | refl with compare2 x x | putTest1Lemma2 x ... | EQ | refl = refl diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaTreeTest.agda.replaced --- a/Paper/src/AgdaTreeTest.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaTreeTest.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,6 +1,6 @@ -test31 = putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ ) 1 1 -$ \t @$\rightarrow$@ putTree1 t 2 2 -$ \t @$\rightarrow$@ putTree1 t 3 3 -$ \t @$\rightarrow$@ putTree1 t 4 4 -$ \t @$\rightarrow$@ getRedBlackTree t 4 -$ \t x @$\rightarrow$@ x +test31 = putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$! ) 1 1 +$ \t !$\rightarrow$! putTree1 t 2 2 +$ \t !$\rightarrow$! putTree1 t 3 3 +$ \t !$\rightarrow$! putTree1 t 4 4 +$ \t !$\rightarrow$! getRedBlackTree t 4 +$ \t x !$\rightarrow$! x diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaTypeClass.agda.replaced --- a/Paper/src/AgdaTypeClass.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaTypeClass.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ record Eq (A : Set) : Set where field - _==_ : A @$\rightarrow$@ A @$\rightarrow$@ Bool + _==_ : A !$\rightarrow$! A !$\rightarrow$! Bool diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/AgdaWhere.agda.replaced --- a/Paper/src/AgdaWhere.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/AgdaWhere.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,7 +1,7 @@ -f : Int @$\rightarrow$@ Int @$\rightarrow$@ Int +f : Int !$\rightarrow$! Int !$\rightarrow$! Int f a b c = (t a) + (t b) + (t c) where t x = x + x + x -f' : Int @$\rightarrow$@ Int @$\rightarrow$@ Int -f' a b c = (a + a + a) + (b + b + b) + (c + c + c) +f!$\prime$! : Int !$\rightarrow$! Int !$\rightarrow$! Int +f!$\prime$! a b c = (a + a + a) + (b + b + b) + (c + c + c) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/CodeSegment.agda.replaced --- a/Paper/src/CodeSegment.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/CodeSegment.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,2 +1,2 @@ -data CodeSegment {l1 l2 : Level} (I : Set l1) (O : Set l2) : Set (l @$\sqcup$@ l1 @$\sqcup$@ l2) where - cs : (I @$\rightarrow$@ O) @$\rightarrow$@ CodeSegment I O +data CodeSegment {l1 l2 : Level} (I : Set l1) (O : Set l2) : Set (l !$\sqcup$! l1 !$\sqcup$! l2) where + cs : (I !$\rightarrow$! O) !$\rightarrow$! CodeSegment I O diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/CodeSegments.agda.replaced --- a/Paper/src/CodeSegments.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/CodeSegments.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -2,10 +2,10 @@ cs2 = cs id cs1 : CodeSegment ds1 ds1 -cs1 = cs (\d @$\rightarrow$@ goto cs2 d) +cs1 = cs (\d !$\rightarrow$! goto cs2 d) cs0 : CodeSegment ds0 ds1 -cs0 = cs (\d @$\rightarrow$@ goto cs1 (record {c = (ds0.a d) + (ds0.b d)})) +cs0 = cs (\d !$\rightarrow$! goto cs1 (record {c = (ds0.a d) + (ds0.b d)})) main : ds1 main = goto cs0 (record {a = 100 ; b = 50}) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/Equiv.agda.replaced --- a/Paper/src/Equiv.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/Equiv.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,1 +1,1 @@ -data _@$\equiv$@_ {a} {A : Set a} (x : A) : A @$\rightarrow$@ Set a where refl : x @$\equiv$@ x \ No newline at end of file +data _!$\equiv$!_ {a} {A : Set a} (x : A) : A !$\rightarrow$! Set a where refl : x !$\equiv$! x \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/Exec.agda.replaced --- a/Paper/src/Exec.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/Exec.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,5 +1,5 @@ exec : {l1 l2 : Level} {I : Set l1} {O : Set l2} {{_ : DataSegment I}} {{_ : DataSegment O}} - @$\rightarrow$@ CodeSegment I O @$\rightarrow$@ Context @$\rightarrow$@ Context + !$\rightarrow$! CodeSegment I O !$\rightarrow$! Context !$\rightarrow$! Context exec {l} {{i}} {{o}} (cs b) c = set o c (b (get i c)) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/Goto.agda.replaced --- a/Paper/src/Goto.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/Goto.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ goto : {l1 l2 : Level} {I : Set l1} {O : Set l2} - @$\rightarrow$@ CodeSegment I O @$\rightarrow$@ I @$\rightarrow$@ O + !$\rightarrow$! CodeSegment I O !$\rightarrow$! I !$\rightarrow$! O goto (cs b) i = b i diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/Maybe.agda.replaced --- a/Paper/src/Maybe.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/Maybe.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ data Maybe {a} (A : Set a) : Set a where - just : (x : A) @$\rightarrow$@ Maybe A + just : (x : A) !$\rightarrow$! Maybe A nothing : Maybe A diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/MetaCodeSegment.agda.replaced --- a/Paper/src/MetaCodeSegment.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/MetaCodeSegment.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -data CodeSegment {l1 l2 : Level} (A : Set l1) (B : Set l2) : Set (l @$\sqcup$@ l1 @$\sqcup$@ l2) where +data CodeSegment {l1 l2 : Level} (A : Set l1) (B : Set l2) : Set (l !$\sqcup$! l1 !$\sqcup$! l2) where cs : {{_ : DataSegment A}} {{_ : DataSegment B}} - @$\rightarrow$@ (A @$\rightarrow$@ B) @$\rightarrow$@ CodeSegment A B + !$\rightarrow$! (A !$\rightarrow$! B) !$\rightarrow$! CodeSegment A B diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/MetaDataSegment.agda.replaced --- a/Paper/src/MetaDataSegment.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/MetaDataSegment.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,7 +1,7 @@ module subtype {l : Level} (Context : Set l) where -record DataSegment {ll : Level} (A : Set ll) : Set (l @$\sqcup$@ ll) where +record DataSegment {ll : Level} (A : Set ll) : Set (l !$\sqcup$! ll) where field - get : Context @$\rightarrow$@ A - set : Context @$\rightarrow$@ A @$\rightarrow$@ Context + get : Context !$\rightarrow$! A + set : Context !$\rightarrow$! A !$\rightarrow$! Context diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/MetaMetaCodeSegment.agda.replaced --- a/Paper/src/MetaMetaCodeSegment.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/MetaMetaCodeSegment.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,15 +1,15 @@ -- meta level -liftContext : {X Y : Set} {{_ : N.DataSegment X}} {{_ : N.DataSegment Y}} @$\rightarrow$@ N.CodeSegment X Y @$\rightarrow$@ N.CodeSegment Context Context -liftContext {{x}} {{y}} (N.cs f) = N.cs (\c @$\rightarrow$@ N.DataSegment.set y c (f (N.DataSegment.get x c))) +liftContext : {X Y : Set} {{_ : N.DataSegment X}} {{_ : N.DataSegment Y}} !$\rightarrow$! N.CodeSegment X Y !$\rightarrow$! N.CodeSegment Context Context +liftContext {{x}} {{y}} (N.cs f) = N.cs (\c !$\rightarrow$! N.DataSegment.set y c (f (N.DataSegment.get x c))) -liftMeta : {X Y : Set} {{_ : M.DataSegment X}} {{_ : M.DataSegment Y}} @$\rightarrow$@ N.CodeSegment X Y @$\rightarrow$@ M.CodeSegment X Y +liftMeta : {X Y : Set} {{_ : M.DataSegment X}} {{_ : M.DataSegment Y}} !$\rightarrow$! N.CodeSegment X Y !$\rightarrow$! M.CodeSegment X Y liftMeta (N.cs f) = M.cs f -gotoMeta : {I O : Set} {{_ : N.DataSegment I}} {{_ : N.DataSegment O}} @$\rightarrow$@ M.CodeSegment Meta Meta @$\rightarrow$@ N.CodeSegment I O @$\rightarrow$@ Meta @$\rightarrow$@ Meta +gotoMeta : {I O : Set} {{_ : N.DataSegment I}} {{_ : N.DataSegment O}} !$\rightarrow$! M.CodeSegment Meta Meta !$\rightarrow$! N.CodeSegment I O !$\rightarrow$! Meta !$\rightarrow$! Meta gotoMeta mCode code m = M.exec mCode (record m {next = (liftContext code)}) push : M.CodeSegment Meta Meta -push = M.cs (\m @$\rightarrow$@ M.exec (liftMeta (Meta.next m)) (record m {c' = Context.c (Meta.context m)})) +push = M.cs (\m !$\rightarrow$! M.exec (liftMeta (Meta.next m)) (record m {c!$\prime$! = Context.c (Meta.context m)})) -- normal level @@ -17,13 +17,13 @@ cs2 = N.cs id cs1 : N.CodeSegment ds1 ds1 -cs1 = N.cs (\d @$\rightarrow$@ N.goto cs2 d) +cs1 = N.cs (\d !$\rightarrow$! N.goto cs2 d) cs0 : N.CodeSegment ds0 ds1 -cs0 = N.cs (\d @$\rightarrow$@ N.goto cs1 (record {c = (ds0.a d) + (ds0.b d)})) +cs0 = N.cs (\d !$\rightarrow$! N.goto cs1 (record {c = (ds0.a d) + (ds0.b d)})) -- meta level (with extended normal) main : Meta -main = gotoMeta push cs0 (record {context = (record {a = 100 ; b = 50 ; c = 70}) ; c' = 0 ; next = (N.cs id)}) --- record {context = record {a = 100 ; b = 50 ; c = 150} ; c' = 70 ; next = (N.cs id)} +main = gotoMeta push cs0 (record {context = (record {a = 100 ; b = 50 ; c = 70}) ; c!$\prime$! = 0 ; next = (N.cs id)}) +-- record {context = record {a = 100 ; b = 50 ; c = 150} ; c!$\prime$! = 70 ; next = (N.cs id)} diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/MetaMetaDataSegment.agda.replaced --- a/Paper/src/MetaMetaDataSegment.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/MetaMetaDataSegment.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -5,7 +5,7 @@ record Meta : Set where field context : Context - c' : Int + c!$\prime$! : Int next : N.CodeSegment Context Context open import subtype Meta as M diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/NatAdd.agda.replaced --- a/Paper/src/NatAdd.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/NatAdd.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,6 +1,6 @@ open import nat module nat_add where -_+_ : Nat @$\rightarrow$@ Nat @$\rightarrow$@ Nat +_+_ : Nat !$\rightarrow$! Nat !$\rightarrow$! Nat O + m = m (S n) + m = S (n + m) \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/NatAddSym.agda.replaced --- a/Paper/src/NatAddSym.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/NatAddSym.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,11 +1,11 @@ open import Relation.Binary.PropositionalEquality open import nat open import nat_add -open @$\equiv$@-Reasoning +open !$\equiv$!-Reasoning module nat_add_sym where -addSym : (n m : Nat) @$\rightarrow$@ n + m @$\equiv$@ m + n +addSym : (n m : Nat) !$\rightarrow$! n + m !$\equiv$! m + n addSym O O = refl addSym O (S m) = cong S (addSym O m) addSym (S n) O = cong S (addSym n O) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/PushPopType.agda.replaced --- a/Paper/src/PushPopType.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/PushPopType.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,9 +1,9 @@ -pushOnce : Meta @$\rightarrow$@ Meta +pushOnce : Meta !$\rightarrow$! Meta pushOnce m = M.exec pushSingleLinkedStackCS m -popOnce : Meta @$\rightarrow$@ Meta +popOnce : Meta !$\rightarrow$! Meta popOnce m = M.exec popSingleLinkedStackCS m -push-pop-type : Meta @$\rightarrow$@ Set@$\_{1}$@ +push-pop-type : Meta !$\rightarrow$! Set!$\_{1}$! push-pop-type meta = - M.exec (M.csComp (M.cs popOnce) (M.cs pushOnce)) meta @$\equiv$@ meta + M.exec (M.csComp (M.cs popOnce) (M.cs pushOnce)) meta !$\equiv$! meta diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/Reasoning.agda.replaced --- a/Paper/src/Reasoning.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/Reasoning.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,21 +1,21 @@ open import Relation.Binary.PropositionalEquality open import nat open import nat_add -open @$\equiv$@-Reasoning +open !$\equiv$!-Reasoning module nat_add_sym_reasoning where -addToRight : (n m : Nat) @$\rightarrow$@ S (n + m) @$\equiv$@ n + (S m) +addToRight : (n m : Nat) !$\rightarrow$! S (n + m) !$\equiv$! n + (S m) addToRight O m = refl addToRight (S n) m = cong S (addToRight n m) -addSym : (n m : Nat) @$\rightarrow$@ n + m @$\equiv$@ m + n +addSym : (n m : Nat) !$\rightarrow$! n + m !$\equiv$! m + n addSym O O = refl addSym O (S m) = cong S (addSym O m) addSym (S n) O = cong S (addSym n O) addSym (S n) (S m) = begin - (S n) + (S m) @$\equiv$@@$\langle$@ refl @$\rangle$@ - S (n + S m) @$\equiv$@@$\langle$@ cong S (addSym n (S m)) @$\rangle$@ - S ((S m) + n) @$\equiv$@@$\langle$@ addToRight (S m) n @$\rangle$@ - S (m + S n) @$\equiv$@@$\langle$@ refl @$\rangle$@ - (S m) + (S n) @$\blacksquare$@ + (S n) + (S m) !$\equiv$!!$\langle$! refl !$\rangle$! + S (n + S m) !$\equiv$!!$\langle$! cong S (addSym n (S m)) !$\rangle$! + S ((S m) + n) !$\equiv$!!$\langle$! addToRight (S m) n !$\rangle$! + S (m + S n) !$\equiv$!!$\langle$! refl !$\rangle$! + (S m) + (S n) !$\blacksquare$! diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/RedBlackTree.agda.replaced --- a/Paper/src/RedBlackTree.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/RedBlackTree.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -2,20 +2,20 @@ open import stack open import Level hiding (zero) -record TreeMethods {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.@$\sqcup$@ n) where +record TreeMethods {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.!$\sqcup$! n) where field - putImpl : treeImpl @$\rightarrow$@ a @$\rightarrow$@ (treeImpl @$\rightarrow$@ t) @$\rightarrow$@ t - getImpl : treeImpl @$\rightarrow$@ (treeImpl @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t + putImpl : treeImpl !$\rightarrow$! a !$\rightarrow$! (treeImpl !$\rightarrow$! t) !$\rightarrow$! t + getImpl : treeImpl !$\rightarrow$! (treeImpl !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t open TreeMethods -record Tree {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.@$\sqcup$@ n) where +record Tree {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.!$\sqcup$! n) where field tree : treeImpl treeMethods : TreeMethods {n} {m} {a} {t} treeImpl - putTree : a @$\rightarrow$@ (Tree treeImpl @$\rightarrow$@ t) @$\rightarrow$@ t - putTree d next = putImpl (treeMethods ) tree d (\t1 @$\rightarrow$@ next (record {tree = t1 ; treeMethods = treeMethods} )) - getTree : (Tree treeImpl @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - getTree next = getImpl (treeMethods ) tree (\t1 d @$\rightarrow$@ next (record {tree = t1 ; treeMethods = treeMethods} ) d ) + putTree : a !$\rightarrow$! (Tree treeImpl !$\rightarrow$! t) !$\rightarrow$! t + putTree d next = putImpl (treeMethods ) tree d (\t1 !$\rightarrow$! next (record {tree = t1 ; treeMethods = treeMethods} )) + getTree : (Tree treeImpl !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + getTree next = getImpl (treeMethods ) tree (\t1 d !$\rightarrow$! next (record {tree = t1 ; treeMethods = treeMethods} ) d ) open Tree @@ -38,11 +38,11 @@ color : Color {n} open Node -record RedBlackTree {n m : Level } {t : Set m} (a k : Set n) : Set (m Level.@$\sqcup$@ n) where +record RedBlackTree {n m : Level } {t : Set m} (a k : Set n) : Set (m Level.!$\sqcup$! n) where field root : Maybe (Node a k) nodeStack : SingleLinkedStack (Node a k) - compare : k @$\rightarrow$@ k @$\rightarrow$@ CompareResult {n} + compare : k !$\rightarrow$! k !$\rightarrow$! CompareResult {n} open RedBlackTree @@ -51,12 +51,12 @@ -- -- put new node at parent node, and rebuild tree to the top -- -{-@$\#$@ TERMINATING @$\#$@-} -- https://agda.readthedocs.io/en/v2.5.3/language/termination-checking.html -replaceNode : {n m : Level } {t : Set m } {a k : Set n} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Node a k @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ t) @$\rightarrow$@ t +{-!$\#$! TERMINATING !$\#$!-} -- https://agda.readthedocs.io/en/v2.5.3/language/termination-checking.html +replaceNode : {n m : Level } {t : Set m } {a k : Set n} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Node a k !$\rightarrow$! (RedBlackTree {n} {m} {t} a k !$\rightarrow$! t) !$\rightarrow$! t replaceNode {n} {m} {t} {a} {k} tree s n0 next = popSingleLinkedStack s ( - \s parent @$\rightarrow$@ replaceNode1 s parent) + \s parent !$\rightarrow$! replaceNode1 s parent) where - replaceNode1 : SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe ( Node a k ) @$\rightarrow$@ t + replaceNode1 : SingleLinkedStack (Node a k) !$\rightarrow$! Maybe ( Node a k ) !$\rightarrow$! t replaceNode1 s Nothing = next ( record tree { root = Just (record n0 { color = Black}) } ) replaceNode1 s (Just n1) with compare tree (key n1) (key n0) ... | EQ = replaceNode tree s ( record n1 { value = value n0 ; left = left n0 ; right = right n0 } ) next @@ -64,12 +64,12 @@ ... | LT = replaceNode tree s ( record n1 { right = Just n0 } ) next -rotateRight : {n m : Level } {t : Set m } {a k : Set n} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ - (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ t) @$\rightarrow$@ t -rotateRight {n} {m} {t} {a} {k} tree s n0 parent rotateNext = getSingleLinkedStack s (\ s n0 @$\rightarrow$@ rotateRight1 tree s n0 parent rotateNext) +rotateRight : {n m : Level } {t : Set m } {a k : Set n} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! + (RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! t) !$\rightarrow$! t +rotateRight {n} {m} {t} {a} {k} tree s n0 parent rotateNext = getSingleLinkedStack s (\ s n0 !$\rightarrow$! rotateRight1 tree s n0 parent rotateNext) where - rotateRight1 : {n m : Level } {t : Set m } {a k : Set n} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ - (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ t) @$\rightarrow$@ t + rotateRight1 : {n m : Level } {t : Set m } {a k : Set n} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! + (RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! t) !$\rightarrow$! t rotateRight1 {n} {m} {t} {a} {k} tree s n0 parent rotateNext with n0 ... | Nothing = rotateNext tree s Nothing n0 ... | Just n1 with parent @@ -81,12 +81,12 @@ ... | _ = rotateNext tree s (Just n1) parent -rotateLeft : {n m : Level } {t : Set m } {a k : Set n} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ - (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ t) @$\rightarrow$@ t -rotateLeft {n} {m} {t} {a} {k} tree s n0 parent rotateNext = getSingleLinkedStack s (\ s n0 @$\rightarrow$@ rotateLeft1 tree s n0 parent rotateNext) +rotateLeft : {n m : Level } {t : Set m } {a k : Set n} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! + (RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! t) !$\rightarrow$! t +rotateLeft {n} {m} {t} {a} {k} tree s n0 parent rotateNext = getSingleLinkedStack s (\ s n0 !$\rightarrow$! rotateLeft1 tree s n0 parent rotateNext) where - rotateLeft1 : {n m : Level } {t : Set m } {a k : Set n} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ - (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ t) @$\rightarrow$@ t + rotateLeft1 : {n m : Level } {t : Set m } {a k : Set n} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! + (RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! t) !$\rightarrow$! t rotateLeft1 {n} {m} {t} {a} {k} tree s n0 parent rotateNext with n0 ... | Nothing = rotateNext tree s Nothing n0 ... | Just n1 with parent @@ -97,11 +97,11 @@ ... | EQ = rotateNext tree s (Just n1) parent ... | _ = rotateNext tree s (Just n1) parent -{-@$\#$@ TERMINATING @$\#$@-} -insertCase5 : {n m : Level } {t : Set m } {a k : Set n} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Node a k @$\rightarrow$@ Node a k @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ t) @$\rightarrow$@ t -insertCase5 {n} {m} {t} {a} {k} tree s n0 parent grandParent next = pop2SingleLinkedStack s (\ s parent grandParent @$\rightarrow$@ insertCase51 tree s n0 parent grandParent next) +{-!$\#$! TERMINATING !$\#$!-} +insertCase5 : {n m : Level } {t : Set m } {a k : Set n} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Node a k !$\rightarrow$! Node a k !$\rightarrow$! (RedBlackTree {n} {m} {t} a k !$\rightarrow$! t) !$\rightarrow$! t +insertCase5 {n} {m} {t} {a} {k} tree s n0 parent grandParent next = pop2SingleLinkedStack s (\ s parent grandParent !$\rightarrow$! insertCase51 tree s n0 parent grandParent next) where - insertCase51 : {n m : Level } {t : Set m } {a k : Set n} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ t) @$\rightarrow$@ t + insertCase51 : {n m : Level } {t : Set m } {a k : Set n} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! (RedBlackTree {n} {m} {t} a k !$\rightarrow$! t) !$\rightarrow$! t insertCase51 {n} {m} {t} {a} {k} tree s n0 parent grandParent next with n0 ... | Nothing = next tree ... | Just n1 with parent | grandParent @@ -113,50 +113,50 @@ ... | Just leftParent1 | Just leftGrandParent1 with compare tree (key n1) (key leftParent1) | compare tree (key leftParent1) (key leftGrandParent1) ... | EQ | EQ = rotateRight tree s n0 parent - (\ tree s n0 parent @$\rightarrow$@ insertCase5 tree s n0 parent1 grandParent1 next) + (\ tree s n0 parent !$\rightarrow$! insertCase5 tree s n0 parent1 grandParent1 next) ... | _ | _ = rotateLeft tree s n0 parent - (\ tree s n0 parent @$\rightarrow$@ insertCase5 tree s n0 parent1 grandParent1 next) + (\ tree s n0 parent !$\rightarrow$! insertCase5 tree s n0 parent1 grandParent1 next) -insertCase4 : {n m : Level } {t : Set m } {a k : Set n} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Node a k @$\rightarrow$@ Node a k @$\rightarrow$@ Node a k @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ t) @$\rightarrow$@ t +insertCase4 : {n m : Level } {t : Set m } {a k : Set n} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Node a k !$\rightarrow$! Node a k !$\rightarrow$! Node a k !$\rightarrow$! (RedBlackTree {n} {m} {t} a k !$\rightarrow$! t) !$\rightarrow$! t insertCase4 {n} {m} {t} {a} {k} tree s n0 parent grandParent next with (right parent) | (left grandParent) ... | Nothing | _ = insertCase5 tree s (Just n0) parent grandParent next ... | _ | Nothing = insertCase5 tree s (Just n0) parent grandParent next ... | Just rightParent | Just leftGrandParent with compare tree (key n0) (key rightParent) | compare tree (key parent) (key leftGrandParent) -... | EQ | EQ = popSingleLinkedStack s (\ s n1 @$\rightarrow$@ rotateLeft tree s (left n0) (Just grandParent) - (\ tree s n0 parent @$\rightarrow$@ insertCase5 tree s n0 rightParent grandParent next)) +... | EQ | EQ = popSingleLinkedStack s (\ s n1 !$\rightarrow$! rotateLeft tree s (left n0) (Just grandParent) + (\ tree s n0 parent !$\rightarrow$! insertCase5 tree s n0 rightParent grandParent next)) ... | _ | _ = insertCase41 tree s n0 parent grandParent next where - insertCase41 : {n m : Level } {t : Set m } {a k : Set n} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Node a k @$\rightarrow$@ Node a k @$\rightarrow$@ Node a k @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ t) @$\rightarrow$@ t + insertCase41 : {n m : Level } {t : Set m } {a k : Set n} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Node a k !$\rightarrow$! Node a k !$\rightarrow$! Node a k !$\rightarrow$! (RedBlackTree {n} {m} {t} a k !$\rightarrow$! t) !$\rightarrow$! t insertCase41 {n} {m} {t} {a} {k} tree s n0 parent grandParent next with (left parent) | (right grandParent) ... | Nothing | _ = insertCase5 tree s (Just n0) parent grandParent next ... | _ | Nothing = insertCase5 tree s (Just n0) parent grandParent next ... | Just leftParent | Just rightGrandParent with compare tree (key n0) (key leftParent) | compare tree (key parent) (key rightGrandParent) - ... | EQ | EQ = popSingleLinkedStack s (\ s n1 @$\rightarrow$@ rotateRight tree s (right n0) (Just grandParent) - (\ tree s n0 parent @$\rightarrow$@ insertCase5 tree s n0 leftParent grandParent next)) + ... | EQ | EQ = popSingleLinkedStack s (\ s n1 !$\rightarrow$! rotateRight tree s (right n0) (Just grandParent) + (\ tree s n0 parent !$\rightarrow$! insertCase5 tree s n0 leftParent grandParent next)) ... | _ | _ = insertCase5 tree s (Just n0) parent grandParent next -colorNode : {n : Level } {a k : Set n} @$\rightarrow$@ Node a k @$\rightarrow$@ Color @$\rightarrow$@ Node a k +colorNode : {n : Level } {a k : Set n} !$\rightarrow$! Node a k !$\rightarrow$! Color !$\rightarrow$! Node a k colorNode old c = record old { color = c } -{-@$\#$@ TERMINATING @$\#$@-} -insertNode : {n m : Level } {t : Set m } {a k : Set n} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Node a k @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ t) @$\rightarrow$@ t +{-!$\#$! TERMINATING !$\#$!-} +insertNode : {n m : Level } {t : Set m } {a k : Set n} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Node a k !$\rightarrow$! (RedBlackTree {n} {m} {t} a k !$\rightarrow$! t) !$\rightarrow$! t insertNode {n} {m} {t} {a} {k} tree s n0 next = get2SingleLinkedStack s (insertCase1 n0) where - insertCase1 : Node a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ Maybe (Node a k) @$\rightarrow$@ t -- placed here to allow mutual recursion + insertCase1 : Node a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! Maybe (Node a k) !$\rightarrow$! t -- placed here to allow mutual recursion -- http://agda.readthedocs.io/en/v2.5.2/language/mutual-recursion.html - insertCase3 : SingleLinkedStack (Node a k) @$\rightarrow$@ Node a k @$\rightarrow$@ Node a k @$\rightarrow$@ Node a k @$\rightarrow$@ t + insertCase3 : SingleLinkedStack (Node a k) !$\rightarrow$! Node a k !$\rightarrow$! Node a k !$\rightarrow$! Node a k !$\rightarrow$! t insertCase3 s n0 parent grandParent with left grandParent | right grandParent ... | Nothing | Nothing = insertCase4 tree s n0 parent grandParent next ... | Nothing | Just uncle = insertCase4 tree s n0 parent grandParent next ... | Just uncle | _ with compare tree ( key uncle ) ( key parent ) ... | EQ = insertCase4 tree s n0 parent grandParent next ... | _ with color uncle - ... | Red = pop2SingleLinkedStack s ( \s p0 p1 @$\rightarrow$@ insertCase1 ( + ... | Red = pop2SingleLinkedStack s ( \s p0 p1 !$\rightarrow$! insertCase1 ( record grandParent { color = Red ; left = Just ( record parent { color = Black } ) ; right = Just ( record uncle { color = Black } ) }) s p0 p1 ) ... | Black = insertCase4 tree s n0 parent grandParent next - insertCase2 : SingleLinkedStack (Node a k) @$\rightarrow$@ Node a k @$\rightarrow$@ Node a k @$\rightarrow$@ Node a k @$\rightarrow$@ t + insertCase2 : SingleLinkedStack (Node a k) !$\rightarrow$! Node a k !$\rightarrow$! Node a k !$\rightarrow$! Node a k !$\rightarrow$! t insertCase2 s n0 parent grandParent with color parent ... | Black = replaceNode tree s n0 next ... | Red = insertCase3 s n0 parent grandParent @@ -168,20 +168,20 @@ ---- -- find node potition to insert or to delete, the path will be in the stack -- -findNode : {n m : Level } {a k : Set n} {t : Set m} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ (Node a k) @$\rightarrow$@ (Node a k) @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Node a k @$\rightarrow$@ t) @$\rightarrow$@ t -findNode {n} {m} {a} {k} {t} tree s n0 n1 next = pushSingleLinkedStack s n1 (\ s @$\rightarrow$@ findNode1 s n1) +findNode : {n m : Level } {a k : Set n} {t : Set m} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! (Node a k) !$\rightarrow$! (Node a k) !$\rightarrow$! (RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Node a k !$\rightarrow$! t) !$\rightarrow$! t +findNode {n} {m} {a} {k} {t} tree s n0 n1 next = pushSingleLinkedStack s n1 (\ s !$\rightarrow$! findNode1 s n1) where - findNode2 : SingleLinkedStack (Node a k) @$\rightarrow$@ (Maybe (Node a k)) @$\rightarrow$@ t + findNode2 : SingleLinkedStack (Node a k) !$\rightarrow$! (Maybe (Node a k)) !$\rightarrow$! t findNode2 s Nothing = next tree s n0 findNode2 s (Just n) = findNode tree s n0 n next - findNode1 : SingleLinkedStack (Node a k) @$\rightarrow$@ (Node a k) @$\rightarrow$@ t + findNode1 : SingleLinkedStack (Node a k) !$\rightarrow$! (Node a k) !$\rightarrow$! t findNode1 s n1 with (compare tree (key n0) (key n1)) - ... | EQ = popSingleLinkedStack s ( \s _ @$\rightarrow$@ next tree s (record n1 { key = key n1 ; value = value n0 } ) ) + ... | EQ = popSingleLinkedStack s ( \s _ !$\rightarrow$! next tree s (record n1 { key = key n1 ; value = value n0 } ) ) ... | GT = findNode2 s (right n1) ... | LT = findNode2 s (left n1) -leafNode : {n : Level } {a k : Set n} @$\rightarrow$@ k @$\rightarrow$@ a @$\rightarrow$@ Node a k +leafNode : {n : Level } {a k : Set n} !$\rightarrow$! k !$\rightarrow$! a !$\rightarrow$! Node a k leafNode k1 value = record { key = k1 ; value = value ; @@ -190,16 +190,16 @@ color = Red } -putRedBlackTree : {n m : Level } {a k : Set n} {t : Set m} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ k @$\rightarrow$@ a @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ t) @$\rightarrow$@ t +putRedBlackTree : {n m : Level } {a k : Set n} {t : Set m} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! k !$\rightarrow$! a !$\rightarrow$! (RedBlackTree {n} {m} {t} a k !$\rightarrow$! t) !$\rightarrow$! t putRedBlackTree {n} {m} {a} {k} {t} tree k1 value next with (root tree) ... | Nothing = next (record tree {root = Just (leafNode k1 value) }) -... | Just n2 = clearSingleLinkedStack (nodeStack tree) (\ s @$\rightarrow$@ findNode tree s (leafNode k1 value) n2 (\ tree1 s n1 @$\rightarrow$@ insertNode tree1 s n1 next)) +... | Just n2 = clearSingleLinkedStack (nodeStack tree) (\ s !$\rightarrow$! findNode tree s (leafNode k1 value) n2 (\ tree1 s n1 !$\rightarrow$! insertNode tree1 s n1 next)) -getRedBlackTree : {n m : Level } {a k : Set n} {t : Set m} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ k @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ (Maybe (Node a k)) @$\rightarrow$@ t) @$\rightarrow$@ t +getRedBlackTree : {n m : Level } {a k : Set n} {t : Set m} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! k !$\rightarrow$! (RedBlackTree {n} {m} {t} a k !$\rightarrow$! (Maybe (Node a k)) !$\rightarrow$! t) !$\rightarrow$! t getRedBlackTree {_} {_} {a} {k} {t} tree k1 cs = checkNode (root tree) module GetRedBlackTree where -- http://agda.readthedocs.io/en/v2.5.2/language/let-and-where.html - search : Node a k @$\rightarrow$@ t - checkNode : Maybe (Node a k) @$\rightarrow$@ t + search : Node a k !$\rightarrow$! t + checkNode : Maybe (Node a k) !$\rightarrow$! t checkNode Nothing = cs tree Nothing checkNode (Just n) = search n search n with compare tree k1 (key n) @@ -209,21 +209,21 @@ open import Data.Nat hiding (compare) -compare@$\mathbb{N}$@ : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ CompareResult {Level.zero} -compare@$\mathbb{N}$@ x y with Data.Nat.compare x y +compare!$\mathbb{N}$! : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! CompareResult {Level.zero} +compare!$\mathbb{N}$! x y with Data.Nat.compare x y ... | less _ _ = LT ... | equal _ = EQ ... | greater _ _ = GT -compare2 : (x y : @$\mathbb{N}$@ ) @$\rightarrow$@ CompareResult {Level.zero} +compare2 : (x y : !$\mathbb{N}$! ) !$\rightarrow$! CompareResult {Level.zero} compare2 zero zero = EQ compare2 (suc _) zero = GT compare2 zero (suc _) = LT compare2 (suc x) (suc y) = compare2 x y -createEmptyRedBlackTree@$\mathbb{N}$@ : { m : Level } (a : Set Level.zero) {t : Set m} @$\rightarrow$@ RedBlackTree {Level.zero} {m} {t} a @$\mathbb{N}$@ -createEmptyRedBlackTree@$\mathbb{N}$@ {m} a {t} = record { +createEmptyRedBlackTree!$\mathbb{N}$! : { m : Level } (a : Set Level.zero) {t : Set m} !$\rightarrow$! RedBlackTree {Level.zero} {m} {t} a !$\mathbb{N}$! +createEmptyRedBlackTree!$\mathbb{N}$! {m} a {t} = record { root = Nothing ; nodeStack = emptySingleLinkedStack ; compare = compare2 diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/ThreePlusOne.agda.replaced --- a/Paper/src/ThreePlusOne.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/ThreePlusOne.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -4,5 +4,5 @@ module three_plus_one where -3+1 : (S (S (S O))) + (S O) @$\equiv$@ (S (S (S (S O)))) +3+1 : (S (S (S O))) + (S O) !$\equiv$! (S (S (S (S O)))) 3+1 = refl \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-func.agda.replaced --- a/Paper/src/agda-func.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-func.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -+1 : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ ++1 : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! +1 m = suc m -- eval +1 zero diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-hoare-interpret.agda.replaced --- a/Paper/src/agda-hoare-interpret.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-hoare-interpret.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,5 +1,5 @@ -{-@$\#$@ TERMINATING @$\#$@-} -interpret : Env @$\rightarrow$@ Comm @$\rightarrow$@ Env +{-!$\#$! TERMINATING !$\#$!-} +interpret : Env !$\rightarrow$! Comm !$\rightarrow$! Env interpret env Skip = env interpret env Abort = env interpret env (PComm x) = x env diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-hoare-prog.agda.replaced --- a/Paper/src/agda-hoare-prog.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-hoare-prog.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,7 +1,7 @@ program : Comm program = - Seq ( PComm (@$\lambda$@ env @$\rightarrow$@ record env {varn = 10})) - $ Seq ( PComm (@$\lambda$@ env @$\rightarrow$@ record env {vari = 0})) - $ While (@$\lambda$@ env @$\rightarrow$@ lt zero (varn env ) ) - (Seq (PComm (@$\lambda$@ env @$\rightarrow$@ record env {vari = ((vari env) + 1)} )) - $ PComm (@$\lambda$@ env @$\rightarrow$@ record env {varn = ((varn env) - 1)} )) + Seq ( PComm (!$\lambda$! env !$\rightarrow$! record env {varn = 10})) + $ Seq ( PComm (!$\lambda$! env !$\rightarrow$! record env {vari = 0})) + $ While (!$\lambda$! env !$\rightarrow$! lt zero (varn env ) ) + (Seq (PComm (!$\lambda$! env !$\rightarrow$! record env {vari = ((vari env) + 1)} )) + $ PComm (!$\lambda$! env !$\rightarrow$! record env {varn = ((varn env) - 1)} )) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-hoare-rule.agda.replaced --- a/Paper/src/agda-hoare-rule.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-hoare-rule.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,27 +1,27 @@ -data HTProof : Cond @$\rightarrow$@ Comm @$\rightarrow$@ Cond @$\rightarrow$@ Set where - PrimRule : {bPre : Cond} @$\rightarrow$@ {pcm : PrimComm} @$\rightarrow$@ {bPost : Cond} @$\rightarrow$@ - (pr : Axiom bPre pcm bPost) @$\rightarrow$@ +data HTProof : Cond !$\rightarrow$! Comm !$\rightarrow$! Cond !$\rightarrow$! Set where + PrimRule : {bPre : Cond} !$\rightarrow$! {pcm : PrimComm} !$\rightarrow$! {bPost : Cond} !$\rightarrow$! + (pr : Axiom bPre pcm bPost) !$\rightarrow$! HTProof bPre (PComm pcm) bPost - SkipRule : (b : Cond) @$\rightarrow$@ HTProof b Skip b - AbortRule : (bPre : Cond) @$\rightarrow$@ (bPost : Cond) @$\rightarrow$@ + SkipRule : (b : Cond) !$\rightarrow$! HTProof b Skip b + AbortRule : (bPre : Cond) !$\rightarrow$! (bPost : Cond) !$\rightarrow$! HTProof bPre Abort bPost - WeakeningRule : {bPre : Cond} @$\rightarrow$@ {bPre' : Cond} @$\rightarrow$@ {cm : Comm} @$\rightarrow$@ - {bPost' : Cond} @$\rightarrow$@ {bPost : Cond} @$\rightarrow$@ - Tautology bPre bPre' @$\rightarrow$@ - HTProof bPre' cm bPost' @$\rightarrow$@ - Tautology bPost' bPost @$\rightarrow$@ + WeakeningRule : {bPre : Cond} !$\rightarrow$! {bPre!$\prime$! : Cond} !$\rightarrow$! {cm : Comm} !$\rightarrow$! + {bPost!$\prime$! : Cond} !$\rightarrow$! {bPost : Cond} !$\rightarrow$! + Tautology bPre bPre!$\prime$! !$\rightarrow$! + HTProof bPre!$\prime$! cm bPost!$\prime$! !$\rightarrow$! + Tautology bPost!$\prime$! bPost !$\rightarrow$! HTProof bPre cm bPost - SeqRule : {bPre : Cond} @$\rightarrow$@ {cm1 : Comm} @$\rightarrow$@ {bMid : Cond} @$\rightarrow$@ - {cm2 : Comm} @$\rightarrow$@ {bPost : Cond} @$\rightarrow$@ - HTProof bPre cm1 bMid @$\rightarrow$@ - HTProof bMid cm2 bPost @$\rightarrow$@ + SeqRule : {bPre : Cond} !$\rightarrow$! {cm1 : Comm} !$\rightarrow$! {bMid : Cond} !$\rightarrow$! + {cm2 : Comm} !$\rightarrow$! {bPost : Cond} !$\rightarrow$! + HTProof bPre cm1 bMid !$\rightarrow$! + HTProof bMid cm2 bPost !$\rightarrow$! HTProof bPre (Seq cm1 cm2) bPost - IfRule : {cmThen : Comm} @$\rightarrow$@ {cmElse : Comm} @$\rightarrow$@ - {bPre : Cond} @$\rightarrow$@ {bPost : Cond} @$\rightarrow$@ - {b : Cond} @$\rightarrow$@ - HTProof (bPre @$\wedge$@ b) cmThen bPost @$\rightarrow$@ - HTProof (bPre @$\wedge$@ neg b) cmElse bPost @$\rightarrow$@ + IfRule : {cmThen : Comm} !$\rightarrow$! {cmElse : Comm} !$\rightarrow$! + {bPre : Cond} !$\rightarrow$! {bPost : Cond} !$\rightarrow$! + {b : Cond} !$\rightarrow$! + HTProof (bPre !$\wedge$! b) cmThen bPost !$\rightarrow$! + HTProof (bPre !$\wedge$! neg b) cmElse bPost !$\rightarrow$! HTProof bPre (If b cmThen cmElse) bPost - WhileRule : {cm : Comm} @$\rightarrow$@ {bInv : Cond} @$\rightarrow$@ {b : Cond} @$\rightarrow$@ - HTProof (bInv @$\wedge$@ b) cm bInv @$\rightarrow$@ - HTProof bInv (While b cm) (bInv @$\wedge$@ neg b) + WhileRule : {cm : Comm} !$\rightarrow$! {bInv : Cond} !$\rightarrow$! {b : Cond} !$\rightarrow$! + HTProof (bInv !$\wedge$! b) cm bInv !$\rightarrow$! + HTProof bInv (While b cm) (bInv !$\wedge$! neg b) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-hoare-satisfies.agda.replaced --- a/Paper/src/agda-hoare-satisfies.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-hoare-satisfies.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -SemComm : Comm @$\rightarrow$@ Rel State (Level.zero) +SemComm : Comm !$\rightarrow$! Rel State (Level.zero) SemComm Skip = RelOpState.deltaGlob SemComm Abort = RelOpState.emptyRel SemComm (PComm pc) = PrimSemComm pc @@ -11,7 +11,7 @@ (SemComm c2)) SemComm (While b c) = RelOpState.unionInf - (@$\lambda$@ (n : $mathbb{N}$) @$\rightarrow$@ + (!$\lambda$! (n : $mathbb{N}$) !$\rightarrow$! RelOpState.comp (RelOpState.repeat n (RelOpState.comp @@ -19,7 +19,7 @@ (SemComm c))) (RelOpState.delta (NotP (SemCond b)))) -Satisfies : Cond @$\rightarrow$@ Comm @$\rightarrow$@ Cond @$\rightarrow$@ Set +Satisfies : Cond !$\rightarrow$! Comm !$\rightarrow$! Cond !$\rightarrow$! Set Satisfies bPre cm bPost - = (s1 : State) @$\rightarrow$@ (s2 : State) @$\rightarrow$@ - SemCond bPre s1 @$\rightarrow$@ SemComm cm s1 s2 @$\rightarrow$@ SemCond bPost s2 + = (s1 : State) !$\rightarrow$! (s2 : State) !$\rightarrow$! + SemCond bPre s1 !$\rightarrow$! SemComm cm s1 s2 !$\rightarrow$! SemCond bPost s2 diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-hoare-soundness.agda.replaced --- a/Paper/src/agda-hoare-soundness.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-hoare-soundness.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,66 +1,66 @@ -Soundness : {bPre : Cond} @$\rightarrow$@ {cm : Comm} @$\rightarrow$@ {bPost : Cond} @$\rightarrow$@ - HTProof bPre cm bPost @$\rightarrow$@ Satisfies bPre cm bPost +Soundness : {bPre : Cond} !$\rightarrow$! {cm : Comm} !$\rightarrow$! {bPost : Cond} !$\rightarrow$! + HTProof bPre cm bPost !$\rightarrow$! Satisfies bPre cm bPost Soundness (PrimRule {bPre} {cm} {bPost} pr) s1 s2 q1 q2 = axiomValid bPre cm bPost pr s1 s2 q1 q2 Soundness {.bPost} {.Skip} {bPost} (SkipRule .bPost) s1 s2 q1 q2 - = substId1 State {Level.zero} {State} {s1} {s2} (proj@$\_{2}$@ q2) (SemCond bPost) q1 + = substId1 State {Level.zero} {State} {s1} {s2} (proj!$\_{2}$! q2) (SemCond bPost) q1 Soundness {bPre} {.Abort} {bPost} (AbortRule .bPre .bPost) s1 s2 q1 () -Soundness (WeakeningRule {bPre} {bPre'} {cm} {bPost'} {bPost} tautPre pr tautPost) +Soundness (WeakeningRule {bPre} {bPre!$\prime$!} {cm} {bPost!$\prime$!} {bPost} tautPre pr tautPost) s1 s2 q1 q2 - = let hyp : Satisfies bPre' cm bPost' + = let hyp : Satisfies bPre!$\prime$! cm bPost!$\prime$! hyp = Soundness pr - in tautValid bPost' bPost tautPost s2 (hyp s1 s2 (tautValid bPre bPre' tautPre s1 q1) q2) + in tautValid bPost!$\prime$! bPost tautPost s2 (hyp s1 s2 (tautValid bPre bPre!$\prime$! tautPre s1 q1) q2) Soundness (SeqRule {bPre} {cm1} {bMid} {cm2} {bPost} pr1 pr2) s1 s2 q1 q2 = let hyp1 : Satisfies bPre cm1 bMid hyp1 = Soundness pr1 hyp2 : Satisfies bMid cm2 bPost hyp2 = Soundness pr2 - in hyp2 (proj@$\_{1}$@ q2) s2 (hyp1 s1 (proj@$\_{1}$@ q2) q1 (proj@$\_{1}$@ (proj@$\_{2}$@ q2))) (proj@$\_{2}$@ (proj@$\_{2}$@ q2)) + in hyp2 (proj!$\_{1}$! q2) s2 (hyp1 s1 (proj!$\_{1}$! q2) q1 (proj!$\_{1}$! (proj!$\_{2}$! q2))) (proj!$\_{2}$! (proj!$\_{2}$! q2)) Soundness (IfRule {cmThen} {cmElse} {bPre} {bPost} {b} pThen pElse) s1 s2 q1 q2 - = let hypThen : Satisfies (bPre @$\wedge$@ b) cmThen bPost + = let hypThen : Satisfies (bPre !$\wedge$! b) cmThen bPost hypThen = Soundness pThen - hypElse : Satisfies (bPre @$\wedge$@ neg b) cmElse bPost + hypElse : Satisfies (bPre !$\wedge$! neg b) cmElse bPost hypElse = Soundness pElse rThen : RelOpState.comp (RelOpState.delta (SemCond b)) - (SemComm cmThen) s1 s2 @$\rightarrow$@ SemCond bPost s2 - rThen = @$\lambda$@ h @$\rightarrow$@ hypThen s1 s2 ((proj@$\_{2}$@ (respAnd bPre b s1)) (q1 , proj@$\_{1}$@ t1)) - (proj@$\_{2}$@ ((proj@$\_{2}$@ (RelOpState.deltaRestPre (SemCond b) (SemComm cmThen) s1 s2)) h)) + (SemComm cmThen) s1 s2 !$\rightarrow$! SemCond bPost s2 + rThen = !$\lambda$! h !$\rightarrow$! hypThen s1 s2 ((proj!$\_{2}$! (respAnd bPre b s1)) (q1 , proj!$\_{1}$! t1)) + (proj!$\_{2}$! ((proj!$\_{2}$! (RelOpState.deltaRestPre (SemCond b) (SemComm cmThen) s1 s2)) h)) rElse : RelOpState.comp (RelOpState.delta (NotP (SemCond b))) - (SemComm cmElse) s1 s2 @$\rightarrow$@ SemCond bPost s2 - rElse = @$\lambda$@ h @$\rightarrow$@ - let t10 : (NotP (SemCond b) s1) @$\times$@ (SemComm cmElse s1 s2) - t10 = proj@$\_{2}$@ (RelOpState.deltaRestPre + (SemComm cmElse) s1 s2 !$\rightarrow$! SemCond bPost s2 + rElse = !$\lambda$! h !$\rightarrow$! + let t10 : (NotP (SemCond b) s1) !$\times$! (SemComm cmElse s1 s2) + t10 = proj!$\_{2}$! (RelOpState.deltaRestPre (NotP (SemCond b)) (SemComm cmElse) s1 s2) h - in hypElse s1 s2 (proj@$\_{2}$@ (respAnd bPre (neg b) s1) - (q1 , (proj@$\_{2}$@ (respNeg b s1) (proj@$\_{1}$@ t10)))) (proj@$\_{2}$@ t10) + in hypElse s1 s2 (proj!$\_{2}$! (respAnd bPre (neg b) s1) + (q1 , (proj!$\_{2}$! (respNeg b s1) (proj!$\_{1}$! t10)))) (proj!$\_{2}$! t10) in when rThen rElse q2 -Soundness (WhileRule {cm'} {bInv} {b} pr) s1 s2 q1 q2 - = proj@$\_{2}$@ (respAnd bInv (neg b) s2) - (lem1 (proj@$\_{1}$@ q2) s2 (proj@$\_{1}$@ t15) , proj@$\_{2}$@ (respNeg b s2) (proj@$\_{2}$@ t15)) +Soundness (WhileRule {cm!$\prime$!} {bInv} {b} pr) s1 s2 q1 q2 + = proj!$\_{2}$! (respAnd bInv (neg b) s2) + (lem1 (proj!$\_{1}$! q2) s2 (proj!$\_{1}$! t15) , proj!$\_{2}$! (respNeg b s2) (proj!$\_{2}$! t15)) where - hyp : Satisfies (bInv @$\wedge$@ b) cm' bInv + hyp : Satisfies (bInv !$\wedge$! b) cm!$\prime$! bInv hyp = Soundness pr - Rel1 : @$\mathbb{N}$@ @$\rightarrow$@ Rel State (Level.zero) - Rel1 = @$\lambda$@ m @$\rightarrow$@ + Rel1 : !$\mathbb{N}$! !$\rightarrow$! Rel State (Level.zero) + Rel1 = !$\lambda$! m !$\rightarrow$! RelOpState.repeat m (RelOpState.comp (RelOpState.delta (SemCond b)) - (SemComm cm')) - t15 : (Rel1 (proj@$\_{1}$@ q2) s1 s2) @$\times$@ (NotP (SemCond b) s2) - t15 = proj@$\_{2}$@ (RelOpState.deltaRestPost - (NotP (SemCond b)) (Rel1 (proj@$\_{1}$@ q2)) s1 s2) (proj@$\_{2}$@ q2) - lem1 : (m : @$\mathbb{N}$@) @$\rightarrow$@ (ss2 : State) @$\rightarrow$@ Rel1 m s1 ss2 @$\rightarrow$@ SemCond bInv ss2 - lem1 zero ss2 h = substId1 State (proj@$\_{2}$@ h) (SemCond bInv) q1 + (SemComm cm!$\prime$!)) + t15 : (Rel1 (proj!$\_{1}$! q2) s1 s2) !$\times$! (NotP (SemCond b) s2) + t15 = proj!$\_{2}$! (RelOpState.deltaRestPost + (NotP (SemCond b)) (Rel1 (proj!$\_{1}$! q2)) s1 s2) (proj!$\_{2}$! q2) + lem1 : (m : !$\mathbb{N}$!) !$\rightarrow$! (ss2 : State) !$\rightarrow$! Rel1 m s1 ss2 !$\rightarrow$! SemCond bInv ss2 + lem1 zero ss2 h = substId1 State (proj!$\_{2}$! h) (SemCond bInv) q1 lem1 (suc n) ss2 h - = let hyp2 : (z : State) @$\rightarrow$@ Rel1 (proj@$\_{1}$@ q2) s1 z @$\rightarrow$@ + = let hyp2 : (z : State) !$\rightarrow$! Rel1 (proj!$\_{1}$! q2) s1 z !$\rightarrow$! SemCond bInv z hyp2 = lem1 n - t22 : (SemCond b (proj@$\_{1}$@ h)) @$\times$@ (SemComm cm' (proj@$\_{1}$@ h) ss2) - t22 = proj@$\_{2}$@ (RelOpState.deltaRestPre (SemCond b) (SemComm cm') (proj@$\_{1}$@ h) ss2) - (proj@$\_{2}$@ (proj@$\_{2}$@ h)) - t23 : SemCond (bInv @$\wedge$@ b) (proj@$\_{1}$@ h) - t23 = proj@$\_{2}$@ (respAnd bInv b (proj@$\_{1}$@ h)) - (hyp2 (proj@$\_{1}$@ h) (proj@$\_{1}$@ (proj@$\_{2}$@ h)) , proj@$\_{1}$@ t22) - in hyp (proj@$\_{1}$@ h) ss2 t23 (proj@$\_{2}$@ t22) + t22 : (SemCond b (proj!$\_{1}$! h)) !$\times$! (SemComm cm!$\prime$! (proj!$\_{1}$! h) ss2) + t22 = proj!$\_{2}$! (RelOpState.deltaRestPre (SemCond b) (SemComm cm!$\prime$!) (proj!$\_{1}$! h) ss2) + (proj!$\_{2}$! (proj!$\_{2}$! h)) + t23 : SemCond (bInv !$\wedge$! b) (proj!$\_{1}$! h) + t23 = proj!$\_{2}$! (respAnd bInv b (proj!$\_{1}$! h)) + (hyp2 (proj!$\_{1}$! h) (proj!$\_{1}$! (proj!$\_{2}$! h)) , proj!$\_{1}$! t22) + in hyp (proj!$\_{1}$! h) ss2 t23 (proj!$\_{2}$! t22) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-hoare-term.agda.replaced --- a/Paper/src/agda-hoare-term.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-hoare-term.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,12 +1,12 @@ -loopP' : {l : Level} {t : Set l} @$\rightarrow$@ Envc @$\rightarrow$@ (exit : Envc @$\rightarrow$@ t) @$\rightarrow$@ t -loopP' record { c10 = c10 ; varn = zero ; vari = vari } exit = +loopP!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! Envc !$\rightarrow$! (exit : Envc !$\rightarrow$! t) !$\rightarrow$! t +loopP!$\prime$! record { c10 = c10 ; varn = zero ; vari = vari } exit = exit (record { c10 = c10 ; varn = zero ; vari = vari }) -loopP' record { c10 = c10 ; varn = (suc varn@$\_{1}$@) ; vari = vari } exit = - whileLoopP' (record { c10 = c10 ; varn = (suc varn@$\_{1}$@) ; vari = vari }) - (@$\lambda$@ env @$\rightarrow$@ loopP' (record { c10 = c10 ; varn = varn@$\_{1}$@ ; vari = vari }) exit ) exit +loopP!$\prime$! record { c10 = c10 ; varn = (suc varn!$\_{1}$!) ; vari = vari } exit = + whileLoopP!$\prime$! (record { c10 = c10 ; varn = (suc varn!$\_{1}$!) ; vari = vari }) + (!$\lambda$! env !$\rightarrow$! loopP!$\prime$! (record { c10 = c10 ; varn = varn!$\_{1}$! ; vari = vari }) exit ) exit -whileTestPCall' : (c10 : @$\mathbb{N}$@ ) @$\rightarrow$@ Envc -whileTestPCall' c10 = whileTestP' {_} {_} c10 (@$\lambda$@ env @$\rightarrow$@ loopP' env (@$\lambda$@ env @$\rightarrow$@ env)) +whileTestPCall!$\prime$! : (c10 : !$\mathbb{N}$! ) !$\rightarrow$! Envc +whileTestPCall!$\prime$! c10 = whileTestP!$\prime$! {_} {_} c10 (!$\lambda$! env !$\rightarrow$! loopP!$\prime$! env (!$\lambda$! env !$\rightarrow$! env)) --- whileTestP' 10 +-- whileTestP!$\prime$! 10 -- record { c10 = 10 ; varn = 0 ; vari = 10 } diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-hoare-while.agda.replaced --- a/Paper/src/agda-hoare-while.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-hoare-while.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,8 +1,8 @@ proof1 : HTProof initCond program termCond proof1 = - SeqRule {@$\lambda$@ e @$\rightarrow$@ true} ( PrimRule empty-case ) - $ SeqRule {@$\lambda$@ e @$\rightarrow$@ Equal (varn e) 10} ( PrimRule lemma1 ) - $ WeakeningRule {@$\lambda$@ e @$\rightarrow$@ (Equal (varn e) 10) @$\wedge$@ (Equal (vari e) 0)} lemma2 ( - WhileRule {_} {@$\lambda$@ e @$\rightarrow$@ Equal ((varn e) + (vari e)) 10} - $ SeqRule (PrimRule {@$\lambda$@ e @$\rightarrow$@ whileInv e @$\wedge$@ lt zero (varn e) } lemma3 ) - $ PrimRule {whileInv'} {_} {whileInv} lemma4 ) lemma5 + SeqRule {!$\lambda$! e !$\rightarrow$! true} ( PrimRule empty-case ) + $ SeqRule {!$\lambda$! e !$\rightarrow$! Equal (varn e) 10} ( PrimRule lemma1 ) + $ WeakeningRule {!$\lambda$! e !$\rightarrow$! (Equal (varn e) 10) !$\wedge$! (Equal (vari e) 0)} lemma2 ( + WhileRule {_} {!$\lambda$! e !$\rightarrow$! Equal ((varn e) + (vari e)) 10} + $ SeqRule (PrimRule {!$\lambda$! e !$\rightarrow$! whileInv e !$\wedge$! lt zero (varn e) } lemma3 ) + $ PrimRule {whileInv!$\prime$!} {_} {whileInv} lemma4 ) lemma5 diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-hoare-whileprog.agda.replaced --- a/Paper/src/agda-hoare-whileprog.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-hoare-whileprog.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,16 +1,16 @@ -whileTestP : {l : Level} {t : Set l} @$\rightarrow$@ (c10 : @$\mathbb{N}$@) @$\rightarrow$@ (Code : Envc @$\rightarrow$@ t) @$\rightarrow$@ t +whileTestP : {l : Level} {t : Set l} !$\rightarrow$! (c10 : !$\mathbb{N}$!) !$\rightarrow$! (Code : Envc !$\rightarrow$! t) !$\rightarrow$! t whileTestP c10 next = next (record {c10 = c10 ; varn = c10 ; vari = 0 }) -whileLoopP' : {l : Level} {t : Set l} @$\rightarrow$@ Envc @$\rightarrow$@ (next : Envc @$\rightarrow$@ t) @$\rightarrow$@ (exit : Envc @$\rightarrow$@ t) @$\rightarrow$@ t -whileLoopP' record { c10 = c10 ; varn = zero ; vari = vari } _ exit = exit record { c10 = c10 ; varn = zero ; vari = vari } -whileLoopP' record { c10 = c10 ; varn = suc varn1 ; vari = vari } next _ = next (record {c10 = c10 ; varn = varn1 ; vari = suc vari }) +whileLoopP!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! Envc !$\rightarrow$! (next : Envc !$\rightarrow$! t) !$\rightarrow$! (exit : Envc !$\rightarrow$! t) !$\rightarrow$! t +whileLoopP!$\prime$! record { c10 = c10 ; varn = zero ; vari = vari } _ exit = exit record { c10 = c10 ; varn = zero ; vari = vari } +whileLoopP!$\prime$! record { c10 = c10 ; varn = suc varn1 ; vari = vari } next _ = next (record {c10 = c10 ; varn = varn1 ; vari = suc vari }) -{-@$\#$@ TERMINATING @$\#$@-} -loopP : {l : Level} {t : Set l} @$\rightarrow$@ Envc @$\rightarrow$@ (exit : Envc @$\rightarrow$@ t) @$\rightarrow$@ t -loopP env exit = whileLoopP' env (@$\lambda$@ env @$\rightarrow$@ loopP env exit ) exit +{-!$\#$! TERMINATING !$\#$!-} +loopP : {l : Level} {t : Set l} !$\rightarrow$! Envc !$\rightarrow$! (exit : Envc !$\rightarrow$! t) !$\rightarrow$! t +loopP env exit = whileLoopP!$\prime$! env (!$\lambda$! env !$\rightarrow$! loopP env exit ) exit -whileTestPCall : (c10 : @$\mathbb{N}$@ ) @$\rightarrow$@ Envc -whileTestPCall c10 = whileTestP {_} {_} c10 (@$\lambda$@ env @$\rightarrow$@ loopP env (@$\lambda$@ env @$\rightarrow$@ env)) +whileTestPCall : (c10 : !$\mathbb{N}$! ) !$\rightarrow$! Envc +whileTestPCall c10 = whileTestP {_} {_} c10 (!$\lambda$! env !$\rightarrow$! loopP env (!$\lambda$! env !$\rightarrow$! env)) -- whileTestPCall 10 -- record { c10 = 10 ; varn = 0 ; vari = 10 } diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-hoare-write.agda.replaced --- a/Paper/src/agda-hoare-write.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-hoare-write.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,15 +1,15 @@ -- Nomal CodeGear -whileLoop' : {l : Level} {t : Set l} @$\rightarrow$@ (n : @$\mathbb{N}$@) @$\rightarrow$@ (env : Envc) - @$\rightarrow$@ (n @$\equiv$@ varn env) - @$\rightarrow$@ (next : Envc @$\rightarrow$@ t) - @$\rightarrow$@ (exit : Envc @$\rightarrow$@ t) @$\rightarrow$@ t -whileLoop' zero env refl _ exit = exit env -whileLoop' (suc n) env refl next _ = next (record env {varn = pred (varn env) ; vari = suc (vari env) }) +whileLoop!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! (n : !$\mathbb{N}$!) !$\rightarrow$! (env : Envc) + !$\rightarrow$! (n !$\equiv$! varn env) + !$\rightarrow$! (next : Envc !$\rightarrow$! t) + !$\rightarrow$! (exit : Envc !$\rightarrow$! t) !$\rightarrow$! t +whileLoop!$\prime$! zero env refl _ exit = exit env +whileLoop!$\prime$! (suc n) env refl next _ = next (record env {varn = pred (varn env) ; vari = suc (vari env) }) -- Hoare Logic base CodeGear -whileLoopPwP' : {l : Level} {t : Set l} @$\rightarrow$@ (n : @$\mathbb{N}$@) @$\rightarrow$@ (env : Envc ) - @$\rightarrow$@ (n @$\equiv$@ varn env) @$\rightarrow$@ (pre : varn env + vari env @$\equiv$@ c10 env) - @$\rightarrow$@ (next : (env : Envc ) @$\rightarrow$@ (pred n @$\equiv$@ varn env) @$\rightarrow$@ (post : varn env + vari env @$\equiv$@ c10 env) @$\rightarrow$@ t) - @$\rightarrow$@ (exit : (env : Envc ) @$\rightarrow$@ (fin : vari env @$\equiv$@ c10 env) @$\rightarrow$@ t) @$\rightarrow$@ t -whileLoopPwP' zero env refl refl next exit = exit env refl -whileLoopPwP' (suc n) env refl refl next exit = next (record env {varn = pred (varn env) ; vari = suc (vari env) }) refl (+-suc n (vari env)) +whileLoopPwP!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! (n : !$\mathbb{N}$!) !$\rightarrow$! (env : Envc ) + !$\rightarrow$! (n !$\equiv$! varn env) !$\rightarrow$! (pre : varn env + vari env !$\equiv$! c10 env) + !$\rightarrow$! (next : (env : Envc ) !$\rightarrow$! (pred n !$\equiv$! varn env) !$\rightarrow$! (post : varn env + vari env !$\equiv$! c10 env) !$\rightarrow$! t) + !$\rightarrow$! (exit : (env : Envc ) !$\rightarrow$! (fin : vari env !$\equiv$! c10 env) !$\rightarrow$! t) !$\rightarrow$! t +whileLoopPwP!$\prime$! zero env refl refl next exit = exit env refl +whileLoopPwP!$\prime$! (suc n) env refl refl next exit = next (record env {varn = pred (varn env) ; vari = suc (vari env) }) refl (+-suc n (vari env)) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-mcg.agda.replaced --- a/Paper/src/agda-mcg.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-mcg.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,5 +1,5 @@ -whileTestPwP : {l : Level} {t : Set l} @$\rightarrow$@ (c10 : @$\mathbb{N}$@) @$\rightarrow$@ - ((env : Envc ) @$\rightarrow$@ (mdg : (vari env @$\equiv$@ 0) @$\wedge$@ (varn env @$\equiv$@ c10 env)) @$\rightarrow$@ t) @$\rightarrow$@ t +whileTestPwP : {l : Level} {t : Set l} !$\rightarrow$! (c10 : !$\mathbb{N}$!) !$\rightarrow$! + ((env : Envc ) !$\rightarrow$! (mdg : (vari env !$\equiv$! 0) !$\wedge$! (varn env !$\equiv$! c10 env)) !$\rightarrow$! t) !$\rightarrow$! t whileTestPwP c10 next = next env record { pi1 = refl ; pi2 = refl } where env : Envc - env = whileTestP c10 ( @$\lambda$@ env @$\rightarrow$@ env ) + env = whileTestP c10 ( !$\lambda$! env !$\rightarrow$! env ) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-mdg.agda.replaced --- a/Paper/src/agda-mdg.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-mdg.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -4,7 +4,7 @@ sf : whileTestState -whileTestStateP : whileTestState @$\rightarrow$@ Envc @$\rightarrow$@ Set -whileTestStateP s1 env = (vari env @$\equiv$@ 0) @$\wedge$@ (varn env @$\equiv$@ c10 env) -whileTestStateP s2 env = (varn env + vari env @$\equiv$@ c10 env) -whileTestStateP sf env = (vari env @$\equiv$@ c10 env) +whileTestStateP : whileTestState !$\rightarrow$! Envc !$\rightarrow$! Set +whileTestStateP s1 env = (vari env !$\equiv$! 0) !$\wedge$! (varn env !$\equiv$! c10 env) +whileTestStateP s2 env = (varn env + vari env !$\equiv$! c10 env) +whileTestStateP sf env = (vari env !$\equiv$! c10 env) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-pattern.agda.replaced --- a/Paper/src/agda-pattern.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-pattern.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -_-_ : Nat @$\rightarrow$@ Nat @$\rightarrow$@ Nat +_-_ : Nat !$\rightarrow$! Nat !$\rightarrow$! Nat n - zero = n zero - suc m = zero suc n - suc m = n - m diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-plus.agda.replaced --- a/Paper/src/agda-plus.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-plus.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ -_+_ : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ +_+_ : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! zero + m = m suc n + m = suc (n + m) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-rewrite.agda.replaced --- a/Paper/src/agda-rewrite.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-rewrite.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ -rewrite-+-comm : (x y : @$\mathbb{N}$@) @$\rightarrow$@ x + y @$\equiv$@ y + x +rewrite-+-comm : (x y : !$\mathbb{N}$!) !$\rightarrow$! x + y !$\equiv$! y + x rewrite-+-comm zero y rewrite (+zero {y}) = refl rewrite-+-comm (suc x) y = ? diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-term.agda.replaced --- a/Paper/src/agda-term.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-term.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -3,24 +3,24 @@ open import Data.Nat.Base open import Relation.Binary.PropositionalEquality -+zero : {y : @$\mathbb{N}$@} @$\rightarrow$@ y + zero @$\equiv$@ y ++zero : {y : !$\mathbb{N}$!} !$\rightarrow$! y + zero !$\equiv$! y +zero {zero} = refl -+zero {suc y} = cong (@$\lambda$@ yy @$\rightarrow$@ suc yy) (+zero {y}) ++zero {suc y} = cong (!$\lambda$! yy !$\rightarrow$! suc yy) (+zero {y}) -+-suc : {x y : @$\mathbb{N}$@} @$\rightarrow$@ x + suc y @$\equiv$@ suc (x + y) ++-suc : {x y : !$\mathbb{N}$!} !$\rightarrow$! x + suc y !$\equiv$! suc (x + y) +-suc {zero} {y} = refl +-suc {suc x} {y} = cong suc (+-suc {x} {y}) -+-comm : (x y : @$\mathbb{N}$@) @$\rightarrow$@ x + y @$\equiv$@ y + x ++-comm : (x y : !$\mathbb{N}$!) !$\rightarrow$! x + y !$\equiv$! y + x +-comm zero y rewrite (+zero {y}) = refl -+-comm (suc x) y = let open @$\equiv$@-Reasoning in ++-comm (suc x) y = let open !$\equiv$!-Reasoning in begin - suc (x + y) @$\equiv$@@$\langle$@@$\rangle$@ - suc (x + y) @$\equiv$@@$\langle$@ cong suc (+-comm x y) @$\rangle$@ - suc (y + x) @$\equiv$@@$\langle$@ sym (+-suc {y} {x}) @$\rangle$@ - y + suc x @$\blacksquare$@ + suc (x + y) !$\equiv$!!$\langle$!!$\rangle$! + suc (x + y) !$\equiv$!!$\langle$! cong suc (+-comm x y) !$\rangle$! + suc (y + x) !$\equiv$!!$\langle$! sym (+-suc {y} {x}) !$\rangle$! + y + suc x !$\blacksquare$! -+-come : (x y : @$\mathbb{N}$@) @$\rightarrow$@ x + y @$\equiv$@ y + x ++-come : (x y : !$\mathbb{N}$!) !$\rightarrow$! x + y !$\equiv$! y + x +-come zero y rewrite (+zero {y}) = refl +-come (suc x) y rewrite (cong suc (+-come x y)) | sym (+-suc {y} {x}) = refl diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-term1.agda.replaced --- a/Paper/src/agda-term1.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-term1.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,10 +1,10 @@ -+-comm : (x y : @$\mathbb{N}$@) @$\rightarrow$@ x + y @$\equiv$@ y + x ++-comm : (x y : !$\mathbb{N}$!) !$\rightarrow$! x + y !$\equiv$! y + x +-comm zero y rewrite (+zero {y}) = refl -+-comm (suc x) y = let open @$\equiv$@-Reasoning in ++-comm (suc x) y = let open !$\equiv$!-Reasoning in begin - ?0 @$\equiv$@@$\langle$@ ?1 @$\rangle$@ - ?2 @$\blacksquare$@ + ?0 !$\equiv$!!$\langle$! ?1 !$\rangle$! + ?2 !$\blacksquare$! --- ?0 : @$\mathbb{N}$@ {(suc x) + y} --- ?1 : suc x + y @$\equiv$@ y + suc x --- ?2 : @$\mathbb{N}$@ +-- ?0 : !$\mathbb{N}$! {(suc x) + y} +-- ?1 : suc x + y !$\equiv$! y + suc x +-- ?2 : !$\mathbb{N}$! diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-term2.agda.replaced --- a/Paper/src/agda-term2.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-term2.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,11 +1,11 @@ -+-comm : (x y : @$\mathbb{N}$@) @$\rightarrow$@ x + y @$\equiv$@ y + x ++-comm : (x y : !$\mathbb{N}$!) !$\rightarrow$! x + y !$\equiv$! y + x +-comm zero y rewrite (+zero {y}) = refl -+-comm (suc x) y = let open @$\equiv$@-Reasoning in ++-comm (suc x) y = let open !$\equiv$!-Reasoning in begin - (suc x) + y @$\equiv$@@$\langle$@@$\rangle$@ - suc (x + y) @$\equiv$@@$\langle$@ cong suc (+-comm x y) @$\rangle$@ - suc (y + x) @$\equiv$@@$\langle$@ ?0 @$\rangle$@ - ?1 @$\blacksquare$@ + (suc x) + y !$\equiv$!!$\langle$!!$\rangle$! + suc (x + y) !$\equiv$!!$\langle$! cong suc (+-comm x y) !$\rangle$! + suc (y + x) !$\equiv$!!$\langle$! ?0 !$\rangle$! + ?1 !$\blacksquare$! --- ?0 : suc (y + x) @$\equiv$@ y + suc x +-- ?0 : suc (y + x) !$\equiv$! y + suc x -- ?1 : y + suc x diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda-term3.agda.replaced --- a/Paper/src/agda-term3.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda-term3.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,12 +1,12 @@ -+-comm : (x y : @$\mathbb{N}$@) @$\rightarrow$@ x + y @$\equiv$@ y + x ++-comm : (x y : !$\mathbb{N}$!) !$\rightarrow$! x + y !$\equiv$! y + x +-comm zero y rewrite (+zero {y}) = refl -+-comm (suc x) y = let open @$\equiv$@-Reasoning in ++-comm (suc x) y = let open !$\equiv$!-Reasoning in begin - suc (x + y) @$\equiv$@@$\langle$@@$\rangle$@ - suc (x + y) @$\equiv$@@$\langle$@ cong suc (+-comm x y) @$\rangle$@ - suc (y + x) @$\equiv$@@$\langle$@ sym (+-suc {y} {x}) @$\rangle$@ - y + suc x @$\blacksquare$@ + suc (x + y) !$\equiv$!!$\langle$!!$\rangle$! + suc (x + y) !$\equiv$!!$\langle$! cong suc (+-comm x y) !$\rangle$! + suc (y + x) !$\equiv$!!$\langle$! sym (+-suc {y} {x}) !$\rangle$! + y + suc x !$\blacksquare$! --- +-suc : {x y : @$\mathbb{N}$@} @$\rightarrow$@ x + suc y @$\equiv$@ suc (x + y) +-- +-suc : {x y : !$\mathbb{N}$!} !$\rightarrow$! x + suc y !$\equiv$! suc (x + y) -- +-suc {zero} {y} = refl -- +-suc {suc x} {y} = cong suc (+-suc {x} {y}) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/And.agda.replaced --- a/Paper/src/agda/And.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/And.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -record _@$\wedge$@_ (A B : Set) : Set where +record _!$\wedge$!_ (A B : Set) : Set where field p1 : A p2 : B diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/Nat.agda.replaced --- a/Paper/src/agda/Nat.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/Nat.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ -data @$\mathbb{N}$@ : Set where - zero : @$\mathbb{N}$@ - suc : (n : @$\mathbb{N}$@) @$\rightarrow$@ @$\mathbb{N}$@ +data !$\mathbb{N}$! : Set where + zero : !$\mathbb{N}$! + suc : (n : !$\mathbb{N}$!) !$\rightarrow$! !$\mathbb{N}$! diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/_Fresh.agda.replaced --- a/Paper/src/agda/_Fresh.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/_Fresh.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,7 +1,7 @@ ------------------------------------------------------------------------ -- The Agda standard library -- --- Fresh lists, a proof relevant variant of Catarina Coquand's contexts in +-- Fresh lists, a proof relevant variant of Catarina Coquand!$\prime$!s contexts in -- "A Formalised Proof of the Soundness and Completeness of a Simply Typed -- Lambda-Calculus with Explicit Substitutions" ------------------------------------------------------------------------ @@ -9,18 +9,18 @@ -- See README.Data.List.Fresh and README.Data.Trie.NonDependent for -- examples of how to use fresh lists. -{-@$\#$@ OPTIONS --without-K --safe @$\#$@-} +{-!$\#$! OPTIONS --without-K --safe !$\#$!-} module Data.List.Fresh where -open import Level using (Level; _@$\sqcup$@_) +open import Level using (Level; _!$\sqcup$!_) open import Data.Bool.Base using (true; false) -open import Data.Unit.Polymorphic.Base using (@$\top$@) -open import Data.Product using (∃; _@$\times$@_; _,_; -,_; proj@$\_{1}$@; proj@$\_{2}$@) -open import Data.List.Relation.Unary.All using (All; []; _@$\text{::}$@_) -open import Data.List.Relation.Unary.AllPairs using (AllPairs; []; _@$\text{::}$@_) +open import Data.Unit.Polymorphic.Base using (!$\top$!) +open import Data.Product using (∃; _!$\times$!_; _,_; -,_; proj!$\_{1}$!; proj!$\_{2}$!) +open import Data.List.Relation.Unary.All using (All; []; _!$\text{::}$!_) +open import Data.List.Relation.Unary.AllPairs using (AllPairs; []; _!$\text{::}$!_) open import Data.Maybe.Base as Maybe using (Maybe; just; nothing) -open import Data.Nat.Base using (@$\mathbb{N}$@; zero; suc) +open import Data.Nat.Base using (!$\mathbb{N}$!; zero; suc) open import Function using (_∘′_; flip; id; _on_) open import Relation.Nullary using (does) open import Relation.Unary as U using (Pred) @@ -41,12 +41,12 @@ module _ {a} (A : Set a) (R : Rel A r) where - data List@$\#$@ : Set (a @$\sqcup$@ r) - fresh : (a : A) (as : List@$\#$@) @$\rightarrow$@ Set r + data List!$\#$! : Set (a !$\sqcup$! r) + fresh : (a : A) (as : List!$\#$!) !$\rightarrow$! Set r - data List@$\#$@ where - [] : List@$\#$@ - cons : (a : A) (as : List@$\#$@) @$\rightarrow$@ fresh a as @$\rightarrow$@ List@$\#$@ + data List!$\#$! where + [] : List!$\#$! + cons : (a : A) (as : List!$\#$!) !$\rightarrow$! fresh a as !$\rightarrow$! List!$\#$! -- Whenever R can be reconstructed by η-expansion (e.g. because it is -- the erasure ⌊_⌋ of a decidable predicate, cf. Relation.Nary) or we @@ -54,158 +54,158 @@ -- We use a different symbol to avoid conflict when importing both Data.List -- and Data.List.Fresh. - infixr 5 _@$\text{::}$@@$\#$@_ - pattern _@$\text{::}$@@$\#$@_ x xs = cons x xs _ + infixr 5 _!$\text{::}$!!$\#$!_ + pattern _!$\text{::}$!!$\#$!_ x xs = cons x xs _ - fresh a [] = @$\top$@ - fresh a (x @$\text{::}$@@$\#$@ xs) = R a x @$\times$@ fresh a xs + fresh a [] = !$\top$! + fresh a (x !$\text{::}$!!$\#$! xs) = R a x !$\times$! fresh a xs -- Convenient notation for freshness making A and R implicit parameters -infix 5 _@$\#$@_ -_@$\#$@_ : {R : Rel A r} (a : A) (as : List@$\#$@ A R) @$\rightarrow$@ Set r -_@$\#$@_ = fresh _ _ +infix 5 _!$\#$!_ +_!$\#$!_ : {R : Rel A r} (a : A) (as : List!$\#$! A R) !$\rightarrow$! Set r +_!$\#$!_ = fresh _ _ ------------------------------------------------------------------------ -- Operations for modifying fresh lists -module _ {R : Rel A r} {S : Rel B s} (f : A @$\rightarrow$@ B) (R@$\Rightarrow$@S : @$\forall$@[ R @$\Rightarrow$@ (S on f) ]) where +module _ {R : Rel A r} {S : Rel B s} (f : A !$\rightarrow$! B) (R!$\Rightarrow$!S : !$\forall$![ R !$\Rightarrow$! (S on f) ]) where - map : List@$\#$@ A R @$\rightarrow$@ List@$\#$@ B S - map-@$\#$@ : @$\forall$@ {a} as @$\rightarrow$@ a @$\#$@ as @$\rightarrow$@ f a @$\#$@ map as + map : List!$\#$! A R !$\rightarrow$! List!$\#$! B S + map-!$\#$! : !$\forall$! {a} as !$\rightarrow$! a !$\#$! as !$\rightarrow$! f a !$\#$! map as map [] = [] - map (cons a as ps) = cons (f a) (map as) (map-@$\#$@ as ps) + map (cons a as ps) = cons (f a) (map as) (map-!$\#$! as ps) - map-@$\#$@ [] _ = _ - map-@$\#$@ (a @$\text{::}$@@$\#$@ as) (p , ps) = R@$\Rightarrow$@S p , map-@$\#$@ as ps + map-!$\#$! [] _ = _ + map-!$\#$! (a !$\text{::}$!!$\#$! as) (p , ps) = R!$\Rightarrow$!S p , map-!$\#$! as ps -module _ {R : Rel B r} (f : A @$\rightarrow$@ B) where +module _ {R : Rel B r} (f : A !$\rightarrow$! B) where - map@$\_{1}$@ : List@$\#$@ A (R on f) @$\rightarrow$@ List@$\#$@ B R - map@$\_{1}$@ = map f id + map!$\_{1}$! : List!$\#$! A (R on f) !$\rightarrow$! List!$\#$! B R + map!$\_{1}$! = map f id -module _ {R : Rel A r} {S : Rel A s} (R@$\Rightarrow$@S : @$\forall$@[ R @$\Rightarrow$@ S ]) where +module _ {R : Rel A r} {S : Rel A s} (R!$\Rightarrow$!S : !$\forall$![ R !$\Rightarrow$! S ]) where - map@$\_{2}$@ : List@$\#$@ A R @$\rightarrow$@ List@$\#$@ A S - map@$\_{2}$@ = map id R@$\Rightarrow$@S + map!$\_{2}$! : List!$\#$! A R !$\rightarrow$! List!$\#$! A S + map!$\_{2}$! = map id R!$\Rightarrow$!S ------------------------------------------------------------------------ -- Views -data Empty {A : Set a} {R : Rel A r} : List@$\#$@ A R @$\rightarrow$@ Set (a @$\sqcup$@ r) where +data Empty {A : Set a} {R : Rel A r} : List!$\#$! A R !$\rightarrow$! Set (a !$\sqcup$! r) where [] : Empty [] -data NonEmpty {A : Set a} {R : Rel A r} : List@$\#$@ A R @$\rightarrow$@ Set (a @$\sqcup$@ r) where - cons : @$\forall$@ x xs pr @$\rightarrow$@ NonEmpty (cons x xs pr) +data NonEmpty {A : Set a} {R : Rel A r} : List!$\#$! A R !$\rightarrow$! Set (a !$\sqcup$! r) where + cons : !$\forall$! x xs pr !$\rightarrow$! NonEmpty (cons x xs pr) ------------------------------------------------------------------------ -- Operations for reducing fresh lists -length : {R : Rel A r} @$\rightarrow$@ List@$\#$@ A R @$\rightarrow$@ @$\mathbb{N}$@ +length : {R : Rel A r} !$\rightarrow$! List!$\#$! A R !$\rightarrow$! !$\mathbb{N}$! length [] = 0 -length (_ @$\text{::}$@@$\#$@ xs) = suc (length xs) +length (_ !$\text{::}$!!$\#$! xs) = suc (length xs) ------------------------------------------------------------------------ -- Operations for constructing fresh lists -pattern [_] a = a @$\text{::}$@@$\#$@ [] +pattern [_] a = a !$\text{::}$!!$\#$! [] -fromMaybe : {R : Rel A r} @$\rightarrow$@ Maybe A @$\rightarrow$@ List@$\#$@ A R +fromMaybe : {R : Rel A r} !$\rightarrow$! Maybe A !$\rightarrow$! List!$\#$! A R fromMaybe nothing = [] fromMaybe (just a) = [ a ] module _ {R : Rel A r} (R-refl : B.Reflexive R) where - replicate : @$\mathbb{N}$@ @$\rightarrow$@ A @$\rightarrow$@ List@$\#$@ A R - replicate-@$\#$@ : (n : @$\mathbb{N}$@) (a : A) @$\rightarrow$@ a @$\#$@ replicate n a + replicate : !$\mathbb{N}$! !$\rightarrow$! A !$\rightarrow$! List!$\#$! A R + replicate-!$\#$! : (n : !$\mathbb{N}$!) (a : A) !$\rightarrow$! a !$\#$! replicate n a replicate zero a = [] - replicate (suc n) a = cons a (replicate n a) (replicate-@$\#$@ n a) + replicate (suc n) a = cons a (replicate n a) (replicate-!$\#$! n a) - replicate-@$\#$@ zero a = _ - replicate-@$\#$@ (suc n) a = R-refl , replicate-@$\#$@ n a + replicate-!$\#$! zero a = _ + replicate-!$\#$! (suc n) a = R-refl , replicate-!$\#$! n a ------------------------------------------------------------------------ -- Operations for deconstructing fresh lists -uncons : {R : Rel A r} @$\rightarrow$@ List@$\#$@ A R @$\rightarrow$@ Maybe (A @$\times$@ List@$\#$@ A R) +uncons : {R : Rel A r} !$\rightarrow$! List!$\#$! A R !$\rightarrow$! Maybe (A !$\times$! List!$\#$! A R) uncons [] = nothing -uncons (a @$\text{::}$@@$\#$@ as) = just (a , as) +uncons (a !$\text{::}$!!$\#$! as) = just (a , as) -head : {R : Rel A r} @$\rightarrow$@ List@$\#$@ A R @$\rightarrow$@ Maybe A -head = Maybe.map proj@$\_{1}$@ ∘′ uncons +head : {R : Rel A r} !$\rightarrow$! List!$\#$! A R !$\rightarrow$! Maybe A +head = Maybe.map proj!$\_{1}$! ∘′ uncons -tail : {R : Rel A r} @$\rightarrow$@ List@$\#$@ A R @$\rightarrow$@ Maybe (List@$\#$@ A R) -tail = Maybe.map proj@$\_{2}$@ ∘′ uncons +tail : {R : Rel A r} !$\rightarrow$! List!$\#$! A R !$\rightarrow$! Maybe (List!$\#$! A R) +tail = Maybe.map proj!$\_{2}$! ∘′ uncons -take : {R : Rel A r} @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ List@$\#$@ A R @$\rightarrow$@ List@$\#$@ A R -take-@$\#$@ : {R : Rel A r} @$\rightarrow$@ @$\forall$@ n a (as : List@$\#$@ A R) @$\rightarrow$@ a @$\#$@ as @$\rightarrow$@ a @$\#$@ take n as +take : {R : Rel A r} !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! List!$\#$! A R !$\rightarrow$! List!$\#$! A R +take-!$\#$! : {R : Rel A r} !$\rightarrow$! !$\forall$! n a (as : List!$\#$! A R) !$\rightarrow$! a !$\#$! as !$\rightarrow$! a !$\#$! take n as take zero xs = [] take (suc n) [] = [] -take (suc n) (cons a as ps) = cons a (take n as) (take-@$\#$@ n a as ps) +take (suc n) (cons a as ps) = cons a (take n as) (take-!$\#$! n a as ps) -take-@$\#$@ zero a xs _ = _ -take-@$\#$@ (suc n) a [] ps = _ -take-@$\#$@ (suc n) a (x @$\text{::}$@@$\#$@ xs) (p , ps) = p , take-@$\#$@ n a xs ps +take-!$\#$! zero a xs _ = _ +take-!$\#$! (suc n) a [] ps = _ +take-!$\#$! (suc n) a (x !$\text{::}$!!$\#$! xs) (p , ps) = p , take-!$\#$! n a xs ps -drop : {R : Rel A r} @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ List@$\#$@ A R @$\rightarrow$@ List@$\#$@ A R +drop : {R : Rel A r} !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! List!$\#$! A R !$\rightarrow$! List!$\#$! A R drop zero as = as drop (suc n) [] = [] -drop (suc n) (a @$\text{::}$@@$\#$@ as) = drop n as +drop (suc n) (a !$\text{::}$!!$\#$! as) = drop n as module _ {P : Pred A p} (P? : U.Decidable P) where - takeWhile : {R : Rel A r} @$\rightarrow$@ List@$\#$@ A R @$\rightarrow$@ List@$\#$@ A R - takeWhile-@$\#$@ : @$\forall$@ {R : Rel A r} a (as : List@$\#$@ A R) @$\rightarrow$@ a @$\#$@ as @$\rightarrow$@ a @$\#$@ takeWhile as + takeWhile : {R : Rel A r} !$\rightarrow$! List!$\#$! A R !$\rightarrow$! List!$\#$! A R + takeWhile-!$\#$! : !$\forall$! {R : Rel A r} a (as : List!$\#$! A R) !$\rightarrow$! a !$\#$! as !$\rightarrow$! a !$\#$! takeWhile as takeWhile [] = [] takeWhile (cons a as ps) with does (P? a) - ... | true = cons a (takeWhile as) (takeWhile-@$\#$@ a as ps) + ... | true = cons a (takeWhile as) (takeWhile-!$\#$! a as ps) ... | false = [] - takeWhile-@$\#$@ a [] _ = _ - takeWhile-@$\#$@ a (x @$\text{::}$@@$\#$@ xs) (p , ps) with does (P? x) - ... | true = p , takeWhile-@$\#$@ a xs ps + takeWhile-!$\#$! a [] _ = _ + takeWhile-!$\#$! a (x !$\text{::}$!!$\#$! xs) (p , ps) with does (P? x) + ... | true = p , takeWhile-!$\#$! a xs ps ... | false = _ - dropWhile : {R : Rel A r} @$\rightarrow$@ List@$\#$@ A R @$\rightarrow$@ List@$\#$@ A R + dropWhile : {R : Rel A r} !$\rightarrow$! List!$\#$! A R !$\rightarrow$! List!$\#$! A R dropWhile [] = [] - dropWhile aas@(a @$\text{::}$@@$\#$@ as) with does (P? a) + dropWhile aas@(a !$\text{::}$!!$\#$! as) with does (P? a) ... | true = dropWhile as ... | false = aas - filter : {R : Rel A r} @$\rightarrow$@ List@$\#$@ A R @$\rightarrow$@ List@$\#$@ A R - filter-@$\#$@ : @$\forall$@ {R : Rel A r} a (as : List@$\#$@ A R) @$\rightarrow$@ a @$\#$@ as @$\rightarrow$@ a @$\#$@ filter as + filter : {R : Rel A r} !$\rightarrow$! List!$\#$! A R !$\rightarrow$! List!$\#$! A R + filter-!$\#$! : !$\forall$! {R : Rel A r} a (as : List!$\#$! A R) !$\rightarrow$! a !$\#$! as !$\rightarrow$! a !$\#$! filter as filter [] = [] filter (cons a as ps) with does (P? a) - ... | true = cons a (filter as) (filter-@$\#$@ a as ps) + ... | true = cons a (filter as) (filter-!$\#$! a as ps) ... | false = filter as - filter-@$\#$@ a [] _ = _ - filter-@$\#$@ a (x @$\text{::}$@@$\#$@ xs) (p , ps) with does (P? x) - ... | true = p , filter-@$\#$@ a xs ps - ... | false = filter-@$\#$@ a xs ps + filter-!$\#$! a [] _ = _ + filter-!$\#$! a (x !$\text{::}$!!$\#$! xs) (p , ps) with does (P? x) + ... | true = p , filter-!$\#$! a xs ps + ... | false = filter-!$\#$! a xs ps ------------------------------------------------------------------------ -- Relationship to List and AllPairs -toList : {R : Rel A r} @$\rightarrow$@ List@$\#$@ A R @$\rightarrow$@ ∃ (AllPairs R) -toAll : @$\forall$@ {R : Rel A r} {a} as @$\rightarrow$@ fresh A R a as @$\rightarrow$@ All (R a) (proj@$\_{1}$@ (toList as)) +toList : {R : Rel A r} !$\rightarrow$! List!$\#$! A R !$\rightarrow$! ∃ (AllPairs R) +toAll : !$\forall$! {R : Rel A r} {a} as !$\rightarrow$! fresh A R a as !$\rightarrow$! All (R a) (proj!$\_{1}$! (toList as)) toList [] = -, [] -toList (cons x xs ps) = -, toAll xs ps @$\text{::}$@ proj@$\_{2}$@ (toList xs) +toList (cons x xs ps) = -, toAll xs ps !$\text{::}$! proj!$\_{2}$! (toList xs) toAll [] ps = [] -toAll (a @$\text{::}$@@$\#$@ as) (p , ps) = p @$\text{::}$@ toAll as ps +toAll (a !$\text{::}$!!$\#$! as) (p , ps) = p !$\text{::}$! toAll as ps -fromList : @$\forall$@ {R : Rel A r} {xs} @$\rightarrow$@ AllPairs R xs @$\rightarrow$@ List@$\#$@ A R -fromList-@$\#$@ : @$\forall$@ {R : Rel A r} {x xs} (ps : AllPairs R xs) @$\rightarrow$@ - All (R x) xs @$\rightarrow$@ x @$\#$@ fromList ps +fromList : !$\forall$! {R : Rel A r} {xs} !$\rightarrow$! AllPairs R xs !$\rightarrow$! List!$\#$! A R +fromList-!$\#$! : !$\forall$! {R : Rel A r} {x xs} (ps : AllPairs R xs) !$\rightarrow$! + All (R x) xs !$\rightarrow$! x !$\#$! fromList ps fromList [] = [] -fromList (r @$\text{::}$@ rs) = cons _ (fromList rs) (fromList-@$\#$@ rs r) +fromList (r !$\text{::}$! rs) = cons _ (fromList rs) (fromList-!$\#$! rs r) -fromList-@$\#$@ [] _ = _ -fromList-@$\#$@ (p @$\text{::}$@ ps) (r @$\text{::}$@ rs) = r , fromList-@$\#$@ ps rs +fromList-!$\#$! [] _ = _ +fromList-!$\#$! (p !$\text{::}$! ps) (r !$\text{::}$! rs) = r , fromList-!$\#$! ps rs diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/abridgement.agda.replaced --- a/Paper/src/agda/abridgement.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/abridgement.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -4,19 +4,19 @@ record env : Set where field - a : @$\mathbb{N}$@ - b : @$\mathbb{N}$@ - c : @$\mathbb{N}$@ + a : !$\mathbb{N}$! + b : !$\mathbb{N}$! + c : !$\mathbb{N}$! open env -patternmatch-default : env @$\rightarrow$@ @$\mathbb{N}$@ +patternmatch-default : env !$\rightarrow$! !$\mathbb{N}$! patternmatch-default record { a = a ; b = b ; c = c } = c -patternmatch-extraction : env @$\rightarrow$@ @$\mathbb{N}$@ +patternmatch-extraction : env !$\rightarrow$! !$\mathbb{N}$! patternmatch-extraction env with c env patternmatch-extraction env | c = c -patternmatch-extraction' : env @$\rightarrow$@ @$\mathbb{N}$@ -patternmatch-extraction' env with c env +patternmatch-extraction!$\prime$! : env !$\rightarrow$! !$\mathbb{N}$! +patternmatch-extraction!$\prime$! env with c env ... | c = c diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/cbc-agda.agda.replaced --- a/Paper/src/agda/cbc-agda.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/cbc-agda.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -5,18 +5,18 @@ record Env : Set where field - varx : @$\mathbb{N}$@ - vary : @$\mathbb{N}$@ + varx : !$\mathbb{N}$! + vary : !$\mathbb{N}$! open Env -plus-com : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +plus-com : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t plus-com env next exit with vary env ... | zero = exit (record { varx = varx env ; vary = vary env }) ... | suc y = next (record { varx = suc (varx env) ; vary = y }) -{-@$\#$@ TERMINATING @$\#$@-} -plus-p : {l : Level} {t : Set l} @$\rightarrow$@ (env : Env) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -plus-p env exit = plus-com env ( @$\lambda$@ env @$\rightarrow$@ plus-p env exit ) exit +{-!$\#$! TERMINATING !$\#$!-} +plus-p : {l : Level} {t : Set l} !$\rightarrow$! (env : Env) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +plus-p env exit = plus-com env ( !$\lambda$! env !$\rightarrow$! plus-p env exit ) exit -plus : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Env -plus x y = plus-p (record { varx = x ; vary = y }) (@$\lambda$@ env @$\rightarrow$@ env) +plus : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! Env +plus x y = plus-p (record { varx = x ; vary = y }) (!$\lambda$! env !$\rightarrow$! env) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/cmp.agda.replaced --- a/Paper/src/agda/cmp.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/cmp.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -4,11 +4,11 @@ open import Data.Nat.Properties as NatProp -- <-cmp open import Relation.Binary -compare_test : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ +compare_test : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! compare_test x y with <-cmp x y -... | tri< a @$\neg$@b @$\neg$@c = y -... | tri≈ @$\neg$@a b @$\neg$@c = x -... | tri> @$\neg$@a @$\neg$@b c = x +... | tri< a !$\neg$!b !$\neg$!c = y +... | tri!$\approx$! !$\neg$!a b !$\neg$!c = x +... | tri> !$\neg$!a !$\neg$!b c = x -- test = compare_test 7 2 -- 7 diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/fresh_test.agda.replaced --- a/Paper/src/agda/fresh_test.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/fresh_test.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -8,7 +8,7 @@ open import Relation.Nary using (⌊_⌋; fromWitness) ISortedList : Set -ISortedList = List@$\#$@ @$\mathbb{N}$@ ⌊ _>?_ ⌋ +ISortedList = List!$\#$! !$\mathbb{N}$! ⌊ _>?_ ⌋ ins : ISortedList -ins = 8 @$\text{::}$@@$\#$@ 4 @$\text{::}$@@$\#$@ 2 @$\text{::}$@@$\#$@ 0 @$\text{::}$@@$\#$@ [] +ins = 8 !$\text{::}$!!$\#$! 4 !$\text{::}$!!$\#$! 2 !$\text{::}$!!$\#$! 0 !$\text{::}$!!$\#$! [] diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/hoare-test.agda.replaced --- a/Paper/src/agda/hoare-test.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/hoare-test.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,6 +1,6 @@ module hoare-test where -open import Data.Nat hiding (_@$\sqcup$@_) +open import Data.Nat hiding (_!$\sqcup$!_) open import Level renaming ( suc to succ ; zero to Zero ) open import Relation.Binary @@ -12,27 +12,27 @@ record Env : Set where field - var-init-x : @$\mathbb{N}$@ - var-init-y : @$\mathbb{N}$@ - var-x : @$\mathbb{N}$@ - var-y : @$\mathbb{N}$@ + var-init-x : !$\mathbb{N}$! + var-init-y : !$\mathbb{N}$! + var-x : !$\mathbb{N}$! + var-y : !$\mathbb{N}$! open Env -plus-com : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +plus-com : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t plus-com env next exit with var-y env ... | zero = exit record env{var-x = var-x env ; var-y = zero} ... | suc y = next record env{var-x = suc (var-x env) ; var-y = y} -plus-init : {l : Level} {t : Set l} @$\rightarrow$@ ( x y : @$\mathbb{N}$@ ) @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ t +plus-init : {l : Level} {t : Set l} !$\rightarrow$! ( x y : !$\mathbb{N}$! ) !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! t plus-init x y next = next (record { var-init-x = x ; var-init-y = y ; var-x = x ; var-y = y }) -{-@$\#$@ TERMINATING @$\#$@-} -plus-p : {l : Level} {t : Set l} @$\rightarrow$@ (env : Env) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -plus-p env exit = plus-com env ( @$\lambda$@ env @$\rightarrow$@ plus-p env exit ) exit +{-!$\#$! TERMINATING !$\#$!-} +plus-p : {l : Level} {t : Set l} !$\rightarrow$! (env : Env) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +plus-p env exit = plus-com env ( !$\lambda$! env !$\rightarrow$! plus-p env exit ) exit -plus : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Env -plus x y = plus-init x y (@$\lambda$@ env @$\rightarrow$@ plus-p env (@$\lambda$@ env @$\rightarrow$@ env)) ---(record { varx = x ; vary = y }) (@$\lambda$@ env @$\rightarrow$@ env) +plus : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! Env +plus x y = plus-init x y (!$\lambda$! env !$\rightarrow$! plus-p env (!$\lambda$! env !$\rightarrow$! env)) +--(record { varx = x ; vary = y }) (!$\lambda$! env !$\rightarrow$! env) -- ここまでplusの定義 @@ -42,33 +42,33 @@ s-doing : mdg-state s-fin : mdg-state -record _@$\wedge$@_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n @$\sqcup$@ m) where +record _!$\wedge$!_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n !$\sqcup$! m) where field proj1 : A proj2 : B -- mcg (meta code gear) -plus-mdg : mdg-state @$\rightarrow$@ Env @$\rightarrow$@ Set -plus-mdg s-init env = (var-x env @$\equiv$@ var-init-x env) @$\wedge$@ (var-y env @$\equiv$@ var-init-y env) -plus-mdg s-doing env = (var-init-x env @$\equiv$@ var-init-x env) @$\wedge$@ (var-init-y env @$\equiv$@ var-init-y env) -- よくないmdg -plus-mdg s-fin env = (var-init-x env @$\equiv$@ var-init-x env) @$\wedge$@ (var-init-y env @$\equiv$@ var-init-y env) -- よくないmdg +plus-mdg : mdg-state !$\rightarrow$! Env !$\rightarrow$! Set +plus-mdg s-init env = (var-x env !$\equiv$! var-init-x env) !$\wedge$! (var-y env !$\equiv$! var-init-y env) +plus-mdg s-doing env = (var-init-x env !$\equiv$! var-init-x env) !$\wedge$! (var-init-y env !$\equiv$! var-init-y env) -- よくないmdg +plus-mdg s-fin env = (var-init-x env !$\equiv$! var-init-x env) !$\wedge$! (var-init-y env !$\equiv$! var-init-y env) -- よくないmdg -- 実行のwrapperを作って、そこでmcgが適切に選ばれて接続をしたい。多分できる気がする。 -plus-init-mcg : {l : Level} {t : Set l} @$\rightarrow$@ (x y : @$\mathbb{N}$@) @$\rightarrow$@ ((env : Env ) @$\rightarrow$@ plus-mdg s-init env @$\rightarrow$@ t) @$\rightarrow$@ t -plus-init-mcg x y next = next ( plus-init x y ( @$\lambda$@ env @$\rightarrow$@ env ) ) record { proj1 = refl ; proj2 = refl } where +plus-init-mcg : {l : Level} {t : Set l} !$\rightarrow$! (x y : !$\mathbb{N}$!) !$\rightarrow$! ((env : Env ) !$\rightarrow$! plus-mdg s-init env !$\rightarrow$! t) !$\rightarrow$! t +plus-init-mcg x y next = next ( plus-init x y ( !$\lambda$! env !$\rightarrow$! env ) ) record { proj1 = refl ; proj2 = refl } where -plus-com-mcg : {l : Level} {t : Set l} @$\rightarrow$@ (env : Env ) @$\rightarrow$@ (next : (env : Env ) @$\rightarrow$@ plus-mdg s-doing env @$\rightarrow$@ t) @$\rightarrow$@ (exit : (env : Env ) @$\rightarrow$@ plus-mdg s-fin env @$\rightarrow$@ t) @$\rightarrow$@ t +plus-com-mcg : {l : Level} {t : Set l} !$\rightarrow$! (env : Env ) !$\rightarrow$! (next : (env : Env ) !$\rightarrow$! plus-mdg s-doing env !$\rightarrow$! t) !$\rightarrow$! (exit : (env : Env ) !$\rightarrow$! plus-mdg s-fin env !$\rightarrow$! t) !$\rightarrow$! t plus-com-mcg env-in next exit with (var-y env-in) -... | suc y = next ( plus-com env-in ( @$\lambda$@ env @$\rightarrow$@ env ) ( @$\lambda$@ env @$\rightarrow$@ env ) ) (record { proj1 = refl ; proj2 = refl }) where +... | suc y = next ( plus-com env-in ( !$\lambda$! env !$\rightarrow$! env ) ( !$\lambda$! env !$\rightarrow$! env ) ) (record { proj1 = refl ; proj2 = refl }) where ... | zero = exit env-in (record { proj1 = refl ; proj2 = refl }) --plus-com-mcg -{-@$\#$@ TERMINATING @$\#$@-} -plus-p-mcg : {l : Level} {t : Set l} @$\rightarrow$@ (env : Env) @$\rightarrow$@ (exit : (env : Env ) @$\rightarrow$@ plus-mdg s-fin env @$\rightarrow$@ t) @$\rightarrow$@ t -plus-p-mcg env exit = plus-com-mcg env (@$\lambda$@ env s @$\rightarrow$@ plus-p-mcg env exit ) exit +{-!$\#$! TERMINATING !$\#$!-} +plus-p-mcg : {l : Level} {t : Set l} !$\rightarrow$! (env : Env) !$\rightarrow$! (exit : (env : Env ) !$\rightarrow$! plus-mdg s-fin env !$\rightarrow$! t) !$\rightarrow$! t +plus-p-mcg env exit = plus-com-mcg env (!$\lambda$! env s !$\rightarrow$! plus-p-mcg env exit ) exit -plus-mcg : (x y : @$\mathbb{N}$@) @$\rightarrow$@ Env -plus-mcg x y = plus-init-mcg x y (@$\lambda$@ env s @$\rightarrow$@ plus-p-mcg env (@$\lambda$@ env s @$\rightarrow$@ env)) +plus-mcg : (x y : !$\mathbb{N}$!) !$\rightarrow$! Env +plus-mcg x y = plus-init-mcg x y (!$\lambda$! env s !$\rightarrow$! plus-p-mcg env (!$\lambda$! env s !$\rightarrow$! env)) test1 = plus-mcg 3 4 @@ -77,15 +77,15 @@ env : Env env = plus-com env-in {!!} {!!} -} ---plus-mdg s-init (plus-p record env{var-x = var-init-x env ; var-y = var-init-y env} (@$\lambda$@ env @$\rightarrow$@ env)) +--plus-mdg s-init (plus-p record env{var-x = var-init-x env ; var-y = var-init-y env} (!$\lambda$! env !$\rightarrow$! env)) {- -whileTestPwP : {l : Level} {t : Set l} @$\rightarrow$@ (c10 : @$\mathbb{N}$@) @$\rightarrow$@ ((env : Envc ) @$\rightarrow$@ whileTestStateP s1 env @$\rightarrow$@ t) @$\rightarrow$@ t +whileTestPwP : {l : Level} {t : Set l} !$\rightarrow$! (c10 : !$\mathbb{N}$!) !$\rightarrow$! ((env : Envc ) !$\rightarrow$! whileTestStateP s1 env !$\rightarrow$! t) !$\rightarrow$! t whileTestPwP c10 next = next env record { pi1 = refl ; pi2 = refl } where env : Envc - env = whileTestP c10 ( @$\lambda$@ env @$\rightarrow$@ env ) + env = whileTestP c10 ( !$\lambda$! env !$\rightarrow$! env ) -} data hoare-cond : Set where @@ -94,7 +94,7 @@ {- -continuation-hoare-triple : {l : Level} {t : Set l} @$\rightarrow$@ hoare-cond @$\rightarrow$@ (next : Env @$\rightarrow$@ t) Set +continuation-hoare-triple : {l : Level} {t : Set l} !$\rightarrow$! hoare-cond !$\rightarrow$! (next : Env !$\rightarrow$! t) Set continuation-hoare-triple p next = continuation-hoare-triple q continuation-hoare-triple q next = continuation-hoare-triple p -} diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/hoare-while.agda.replaced --- a/Paper/src/agda/hoare-while.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/hoare-while.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -7,92 +7,92 @@ record Envc : Set (succ Zero) where field - c10 : @$\mathbb{N}$@ - varn : @$\mathbb{N}$@ - vari : @$\mathbb{N}$@ + c10 : !$\mathbb{N}$! + varn : !$\mathbb{N}$! + vari : !$\mathbb{N}$! open Envc -whileTestP : {l : Level} {t : Set l} @$\rightarrow$@ (c10 : @$\mathbb{N}$@) @$\rightarrow$@ (next : Envc @$\rightarrow$@ t) @$\rightarrow$@ t +whileTestP : {l : Level} {t : Set l} !$\rightarrow$! (c10 : !$\mathbb{N}$!) !$\rightarrow$! (next : Envc !$\rightarrow$! t) !$\rightarrow$! t whileTestP c10 next = next (record {varn = c10 ; vari = 0 ; c10 = c10 } ) -whileLoopP : {l : Level} {t : Set l} @$\rightarrow$@ Envc @$\rightarrow$@ (next : Envc @$\rightarrow$@ t) @$\rightarrow$@ (exit : Envc @$\rightarrow$@ t) @$\rightarrow$@ t +whileLoopP : {l : Level} {t : Set l} !$\rightarrow$! Envc !$\rightarrow$! (next : Envc !$\rightarrow$! t) !$\rightarrow$! (exit : Envc !$\rightarrow$! t) !$\rightarrow$! t whileLoopP env next exit with (varn env) ... | zero = exit env ... | suc n = exit (record env { varn = n ; vari = (suc n) }) -{-@$\#$@ TERMINATING @$\#$@-} -loopP : {l : Level} {t : Set l} @$\rightarrow$@ Envc @$\rightarrow$@ (exit : Envc @$\rightarrow$@ t) @$\rightarrow$@ t -loopP env exit = whileLoopP env (@$\lambda$@ env @$\rightarrow$@ loopP env exit ) exit +{-!$\#$! TERMINATING !$\#$!-} +loopP : {l : Level} {t : Set l} !$\rightarrow$! Envc !$\rightarrow$! (exit : Envc !$\rightarrow$! t) !$\rightarrow$! t +loopP env exit = whileLoopP env (!$\lambda$! env !$\rightarrow$! loopP env exit ) exit -whileTestPCall : (c10 : @$\mathbb{N}$@ ) @$\rightarrow$@ Envc -whileTestPCall c10 = whileTestP {_} {_} c10 (@$\lambda$@ env @$\rightarrow$@ loopP env (@$\lambda$@ env @$\rightarrow$@ env)) +whileTestPCall : (c10 : !$\mathbb{N}$! ) !$\rightarrow$! Envc +whileTestPCall c10 = whileTestP {_} {_} c10 (!$\lambda$! env !$\rightarrow$! loopP env (!$\lambda$! env !$\rightarrow$! env)) --- open import Data.Empty ---open import Relation.Nullary using (@$\neg$@_; Dec; yes; no) +--open import Relation.Nullary using (!$\neg$!_; Dec; yes; no) --open import Agda.Builtin.Unit open import utilities open import Relation.Binary.PropositionalEquality -open _@$\wedge$@_ +open _!$\wedge$!_ data whileTestState : Set where s1 : whileTestState s2 : whileTestState sf : whileTestState -whileTestStateP : whileTestState @$\rightarrow$@ Envc @$\rightarrow$@ Set -whileTestStateP s1 env = (vari env @$\equiv$@ 0) @$\wedge$@ (varn env @$\equiv$@ c10 env) -whileTestStateP s2 env = (varn env + vari env @$\equiv$@ c10 env) -whileTestStateP sf env = (vari env @$\equiv$@ c10 env) +whileTestStateP : whileTestState !$\rightarrow$! Envc !$\rightarrow$! Set +whileTestStateP s1 env = (vari env !$\equiv$! 0) !$\wedge$! (varn env !$\equiv$! c10 env) +whileTestStateP s2 env = (varn env + vari env !$\equiv$! c10 env) +whileTestStateP sf env = (vari env !$\equiv$! c10 env) -whileTestPwP : {l : Level} {t : Set l} @$\rightarrow$@ (c10 : @$\mathbb{N}$@) @$\rightarrow$@ ((env : Envc ) @$\rightarrow$@ whileTestStateP s1 env @$\rightarrow$@ t) @$\rightarrow$@ t +whileTestPwP : {l : Level} {t : Set l} !$\rightarrow$! (c10 : !$\mathbb{N}$!) !$\rightarrow$! ((env : Envc ) !$\rightarrow$! whileTestStateP s1 env !$\rightarrow$! t) !$\rightarrow$! t whileTestPwP c10 next = next env record { pi1 = refl ; pi2 = refl } where env : Envc - env = whileTestP c10 ( @$\lambda$@ env @$\rightarrow$@ env ) + env = whileTestP c10 ( !$\lambda$! env !$\rightarrow$! env ) -whileLoopPwP : {l : Level} {t : Set l} @$\rightarrow$@ (env : Envc ) @$\rightarrow$@ whileTestStateP s2 env - @$\rightarrow$@ (next : (env : Envc ) @$\rightarrow$@ whileTestStateP s2 env @$\rightarrow$@ t) - @$\rightarrow$@ (exit : (env : Envc ) @$\rightarrow$@ whileTestStateP sf env @$\rightarrow$@ t) @$\rightarrow$@ t +whileLoopPwP : {l : Level} {t : Set l} !$\rightarrow$! (env : Envc ) !$\rightarrow$! whileTestStateP s2 env + !$\rightarrow$! (next : (env : Envc ) !$\rightarrow$! whileTestStateP s2 env !$\rightarrow$! t) + !$\rightarrow$! (exit : (env : Envc ) !$\rightarrow$! whileTestStateP sf env !$\rightarrow$! t) !$\rightarrow$! t whileLoopPwP env s next exit with <-cmp 0 (varn env) -whileLoopPwP env s next exit | tri≈ @$\neg$@a b @$\neg$@c = exit env (lem (sym b) s) +whileLoopPwP env s next exit | tri!$\approx$! !$\neg$!a b !$\neg$!c = exit env (lem (sym b) s) where - lem : (varn env @$\equiv$@ 0) @$\rightarrow$@ (varn env + vari env @$\equiv$@ c10 env) @$\rightarrow$@ vari env @$\equiv$@ c10 env + lem : (varn env !$\equiv$! 0) !$\rightarrow$! (varn env + vari env !$\equiv$! c10 env) !$\rightarrow$! vari env !$\equiv$! c10 env lem refl refl = refl -whileLoopPwP env s next exit | tri< a @$\neg$@b @$\neg$@c = next (record env {varn = (varn env) - 1 ; vari = (vari env) + 1 }) (proof5 a) +whileLoopPwP env s next exit | tri< a !$\neg$!b !$\neg$!c = next (record env {varn = (varn env) - 1 ; vari = (vari env) + 1 }) (proof5 a) where - 1<0 : 1 @$\leq$@ zero @$\rightarrow$@ @$\bot$@ + 1<0 : 1 !$\leq$! zero !$\rightarrow$! !$\bot$! 1<0 () - proof5 : (suc zero @$\leq$@ (varn env)) @$\rightarrow$@ ((varn env ) - 1) + (vari env + 1) @$\equiv$@ c10 env - proof5 (s@$\leq$@s lt) with varn env - proof5 (s@$\leq$@s z@$\leq$@n) | zero = @$\bot$@-elim (1<0 a) - proof5 (s@$\leq$@s (z@$\leq$@n {n'}) ) | suc n = let open @$\equiv$@-Reasoning in + proof5 : (suc zero !$\leq$! (varn env)) !$\rightarrow$! ((varn env ) - 1) + (vari env + 1) !$\equiv$! c10 env + proof5 (s!$\leq$!s lt) with varn env + proof5 (s!$\leq$!s z!$\leq$!n) | zero = !$\bot$!-elim (1<0 a) + proof5 (s!$\leq$!s (z!$\leq$!n {n!$\prime$!}) ) | suc n = let open !$\equiv$!-Reasoning in begin - n' + (vari env + 1) - @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ n' + z ) ( +-sym {vari env} {1} ) @$\rangle$@ - n' + (1 + vari env ) - @$\equiv$@@$\langle$@ sym ( +-assoc (n') 1 (vari env) ) @$\rangle$@ - (n' + 1) + vari env - @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ z + vari env ) +1@$\equiv$@suc @$\rangle$@ - (suc n' ) + vari env - @$\equiv$@@$\langle$@@$\rangle$@ + n!$\prime$! + (vari env + 1) + !$\equiv$!!$\langle$! cong ( !$\lambda$! z !$\rightarrow$! n!$\prime$! + z ) ( +-sym {vari env} {1} ) !$\rangle$! + n!$\prime$! + (1 + vari env ) + !$\equiv$!!$\langle$! sym ( +-assoc (n!$\prime$!) 1 (vari env) ) !$\rangle$! + (n!$\prime$! + 1) + vari env + !$\equiv$!!$\langle$! cong ( !$\lambda$! z !$\rightarrow$! z + vari env ) +1!$\equiv$!suc !$\rangle$! + (suc n!$\prime$! ) + vari env + !$\equiv$!!$\langle$!!$\rangle$! varn env + vari env - @$\equiv$@@$\langle$@ s @$\rangle$@ + !$\equiv$!!$\langle$! s !$\rangle$! c10 env - @$\blacksquare$@ + !$\blacksquare$! -whileLoopPwP' : {l : Level} {t : Set l} @$\rightarrow$@ (n : @$\mathbb{N}$@) @$\rightarrow$@ (env : Envc ) @$\rightarrow$@ (n @$\equiv$@ varn env) @$\rightarrow$@ whileTestStateP s2 env - @$\rightarrow$@ (next : (env : Envc ) @$\rightarrow$@ (pred n @$\equiv$@ varn env) @$\rightarrow$@ whileTestStateP s2 env @$\rightarrow$@ t) - @$\rightarrow$@ (exit : (env : Envc ) @$\rightarrow$@ whileTestStateP sf env @$\rightarrow$@ t) @$\rightarrow$@ t -whileLoopPwP' zero env refl refl next exit = exit env refl -whileLoopPwP' (suc n) env refl refl next exit = next (record env {varn = pred (varn env) ; vari = suc (vari env) }) refl (+-suc n (vari env)) +whileLoopPwP!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! (n : !$\mathbb{N}$!) !$\rightarrow$! (env : Envc ) !$\rightarrow$! (n !$\equiv$! varn env) !$\rightarrow$! whileTestStateP s2 env + !$\rightarrow$! (next : (env : Envc ) !$\rightarrow$! (pred n !$\equiv$! varn env) !$\rightarrow$! whileTestStateP s2 env !$\rightarrow$! t) + !$\rightarrow$! (exit : (env : Envc ) !$\rightarrow$! whileTestStateP sf env !$\rightarrow$! t) !$\rightarrow$! t +whileLoopPwP!$\prime$! zero env refl refl next exit = exit env refl +whileLoopPwP!$\prime$! (suc n) env refl refl next exit = next (record env {varn = pred (varn env) ; vari = suc (vari env) }) refl (+-suc n (vari env)) -whileTestPSemSound : (c : @$\mathbb{N}$@ ) (output : Envc ) @$\rightarrow$@ output @$\equiv$@ whileTestP c (@$\lambda$@ e @$\rightarrow$@ e) @$\rightarrow$@ @$\top$@ implies ((vari output @$\equiv$@ 0) @$\wedge$@ (varn output @$\equiv$@ c)) +whileTestPSemSound : (c : !$\mathbb{N}$! ) (output : Envc ) !$\rightarrow$! output !$\equiv$! whileTestP c (!$\lambda$! e !$\rightarrow$! e) !$\rightarrow$! !$\top$! implies ((vari output !$\equiv$! 0) !$\wedge$! (varn output !$\equiv$! c)) whileTestPSemSound c output refl = whileTestPSem c diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/hoare-while1.agda.replaced --- a/Paper/src/agda/hoare-while1.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/hoare-while1.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -13,29 +13,29 @@ record Env : Set (Suc Zero) where field - varn : @$\mathbb{N}$@ - vari : @$\mathbb{N}$@ + varn : !$\mathbb{N}$! + vari : !$\mathbb{N}$! open Env record WhileTest {m : Level } {t : Set m } : Set (Suc m) where field env : Env - whileInit : (c10 : @$\mathbb{N}$@) @$\rightarrow$@ (Env @$\rightarrow$@ t) @$\rightarrow$@ t + whileInit : (c10 : !$\mathbb{N}$!) !$\rightarrow$! (Env !$\rightarrow$! t) !$\rightarrow$! t whileInit c10 next = next (record {varn = c10 ; vari = 0 } ) - whileLoop : Env @$\rightarrow$@ (Code : Env @$\rightarrow$@ t) @$\rightarrow$@ t + whileLoop : Env !$\rightarrow$! (Code : Env !$\rightarrow$! t) !$\rightarrow$! t whileLoop env next = whileLoop1 (varn env) env where - whileLoop1 : @$\mathbb{N}$@ @$\rightarrow$@ Env @$\rightarrow$@ t + whileLoop1 : !$\mathbb{N}$! !$\rightarrow$! Env !$\rightarrow$! t whileLoop1 zero env = next env whileLoop1 (suc t ) env = whileLoop1 t (record env {varn = t ; vari = (vari env) + 1}) - whileTest : (c10 : @$\mathbb{N}$@) @$\rightarrow$@ (Env @$\rightarrow$@ t) @$\rightarrow$@ t - whileTest c10 next = whileInit c10 $ @$\lambda$@ env @$\rightarrow$@ whileLoop env next + whileTest : (c10 : !$\mathbb{N}$!) !$\rightarrow$! (Env !$\rightarrow$! t) !$\rightarrow$! t + whileTest c10 next = whileInit c10 $ !$\lambda$! env !$\rightarrow$! whileLoop env next open WhileTest -createWhileTest : {m : Level} {t : Set m } @$\rightarrow$@ WhileTest {m} {t} +createWhileTest : {m : Level} {t : Set m } !$\rightarrow$! WhileTest {m} {t} createWhileTest = record { env = record { varn = 0; vari = 0 } } -test2 : @$\mathbb{N}$@ -test2 = whileTest createWhileTest 10 $ @$\lambda$@ e @$\rightarrow$@ vari e +test2 : !$\mathbb{N}$! +test2 = whileTest createWhileTest 10 $ !$\lambda$! e !$\rightarrow$! vari e diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/lambda.agda.replaced --- a/Paper/src/agda/lambda.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/lambda.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -2,27 +2,27 @@ open import Data.Nat -ll+_ : (x y : @$\mathbb{N}$@) @$\rightarrow$@ @$\mathbb{N}$@ -ll+ zero = @$\lambda$@ y @$\rightarrow$@ y -ll+ suc x = @$\lambda$@ y @$\rightarrow$@ (ll+ x) (suc y) +ll+_ : (x y : !$\mathbb{N}$!) !$\rightarrow$! !$\mathbb{N}$! +ll+ zero = !$\lambda$! y !$\rightarrow$! y +ll+ suc x = !$\lambda$! y !$\rightarrow$! (ll+ x) (suc y) test = (ll+ 5) 7 -- +1をしたのち、もう一度+1をする関数を定義する場合 -+1 : (x : @$\mathbb{N}$@ )@$\rightarrow$@ @$\mathbb{N}$@ ++1 : (x : !$\mathbb{N}$! )!$\rightarrow$! !$\mathbb{N}$! +1 x = suc x -+n : (a : @$\mathbb{N}$@) @$\rightarrow$@ (x : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@) @$\rightarrow$@ @$\mathbb{N}$@ ++n : (a : !$\mathbb{N}$!) !$\rightarrow$! (x : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$!) !$\rightarrow$! !$\mathbb{N}$! +n a x = x a -test*2 : (a : @$\mathbb{N}$@) @$\rightarrow$@ @$\mathbb{N}$@ -test*2 a = +n a (@$\lambda$@ z @$\rightarrow$@ z + 2) +test*2 : (a : !$\mathbb{N}$!) !$\rightarrow$! !$\mathbb{N}$! +test*2 a = +n a (!$\lambda$! z !$\rightarrow$! z + 2) -test*2' : (a : @$\mathbb{N}$@) @$\rightarrow$@ @$\mathbb{N}$@ -test*2' a = +n a (@$\lambda$@ z @$\rightarrow$@ +n z (@$\lambda$@ z @$\rightarrow$@ z)) +test*2!$\prime$! : (a : !$\mathbb{N}$!) !$\rightarrow$! !$\mathbb{N}$! +test*2!$\prime$! a = +n a (!$\lambda$! z !$\rightarrow$! +n z (!$\lambda$! z !$\rightarrow$! z)) -@$\lambda$@'+2 : (x : @$\mathbb{N}$@) @$\rightarrow$@ @$\mathbb{N}$@ -@$\lambda$@'+2 d = {!!} -- (@$\lambda$@ x @$\rightarrow$@ x +1) +!$\lambda$!!$\prime$!+2 : (x : !$\mathbb{N}$!) !$\rightarrow$! !$\mathbb{N}$! +!$\lambda$!!$\prime$!+2 d = {!!} -- (!$\lambda$! x !$\rightarrow$! x +1) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/list-any.agda.replaced --- a/Paper/src/agda/list-any.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/list-any.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,14 +1,14 @@ module list-any where import Relation.Binary.PropositionalEquality as Eq -open Eq using (_@$\equiv$@_; refl; sym; trans; cong) -open Eq.@$\equiv$@-Reasoning -open import Data.Bool using (Bool; true; false; T; _@$\wedge$@_; _∨_; not) -open import Data.Nat using (@$\mathbb{N}$@; zero; suc; _+_; _*_; _∸_; _@$\leq$@_; s@$\leq$@s; z@$\leq$@n) +open Eq using (_!$\equiv$!_; refl; sym; trans; cong) +open Eq.!$\equiv$!-Reasoning +open import Data.Bool using (Bool; true; false; T; _!$\wedge$!_; _∨_; not) +open import Data.Nat using (!$\mathbb{N}$!; zero; suc; _+_; _*_; _∸_; _!$\leq$!_; s!$\leq$!s; z!$\leq$!n) open import Data.Nat.Properties using (+-assoc; +-identityˡ; +-identityʳ; *-assoc; *-identityˡ; *-identityʳ) -open import Relation.Nullary using (@$\neg$@_; Dec; yes; no) -open import Data.Product using (_@$\times$@_; ∃; ∃-syntax) renaming (_,_ to @$\langle$@_,_@$\rangle$@) +open import Relation.Nullary using (!$\neg$!_; Dec; yes; no) +open import Data.Product using (_!$\times$!_; ∃; ∃-syntax) renaming (_,_ to !$\langle$!_,_!$\rangle$!) open import Function using (_∘_) open import Level using (Level) --open import plfa.part1.Isomorphism using (_≃_; _⇔_) @@ -21,52 +21,52 @@ -- infix 4 _∈_ _∉_ -test-l : List @$\mathbb{N}$@ -test-l = 1 @$\text{::}$@ 2 @$\text{::}$@ [] +test-l : List !$\mathbb{N}$! +test-l = 1 !$\text{::}$! 2 !$\text{::}$! [] -data Any-test {A : Set} (P : A @$\rightarrow$@ Set) : List A @$\rightarrow$@ Set where - here : @$\forall$@ {x : A} {xs : List A} @$\rightarrow$@ P x @$\rightarrow$@ Any-test P (x @$\text{::}$@ xs) - there : @$\forall$@ {x : A} {xs : List A} @$\rightarrow$@ Any-test P xs @$\rightarrow$@ Any-test P (x @$\text{::}$@ xs) +data Any-test {A : Set} (P : A !$\rightarrow$! Set) : List A !$\rightarrow$! Set where + here : !$\forall$! {x : A} {xs : List A} !$\rightarrow$! P x !$\rightarrow$! Any-test P (x !$\text{::}$! xs) + there : !$\forall$! {x : A} {xs : List A} !$\rightarrow$! Any-test P xs !$\rightarrow$! Any-test P (x !$\text{::}$! xs) {- -_∈_ : @$\forall$@ {A : Set} (x : A) (xs : List A) @$\rightarrow$@ Set -x ∈ xs = Any (x @$\equiv$@_) xs +_∈_ : !$\forall$! {A : Set} (x : A) (xs : List A) !$\rightarrow$! Set +x ∈ xs = Any (x !$\equiv$!_) xs -} -_∈1_ : @$\forall$@ (n : @$\mathbb{N}$@) (xs : List @$\mathbb{N}$@) @$\rightarrow$@ Set -n ∈1 [] = Any-test (n @$\equiv$@_) [] -n ∈1 l@(x @$\text{::}$@ xs) with <-cmp n x -... | tri< a @$\neg$@b @$\neg$@c = Any-test (n @$\equiv$@_) xs -... | tri≈ @$\neg$@a b @$\neg$@c = Any-test (n @$\equiv$@_) l -... | tri> @$\neg$@a @$\neg$@b c = Any-test (n @$\equiv$@_) xs +_∈1_ : !$\forall$! (n : !$\mathbb{N}$!) (xs : List !$\mathbb{N}$!) !$\rightarrow$! Set +n ∈1 [] = Any-test (n !$\equiv$!_) [] +n ∈1 l@(x !$\text{::}$! xs) with <-cmp n x +... | tri< a !$\neg$!b !$\neg$!c = Any-test (n !$\equiv$!_) xs +... | tri!$\approx$! !$\neg$!a b !$\neg$!c = Any-test (n !$\equiv$!_) l +... | tri> !$\neg$!a !$\neg$!b c = Any-test (n !$\equiv$!_) xs test : 1 ∈1 test-l test = here refl -data Any (P : @$\mathbb{N}$@ @$\rightarrow$@ Set) : rbt @$\rightarrow$@ Set where - here : @$\forall$@ {x : @$\mathbb{N}$@} {xs : rbt} @$\rightarrow$@ P x @$\rightarrow$@ Any P xs - there : @$\forall$@ {x : @$\mathbb{N}$@} {xs : rbt} @$\rightarrow$@ Any P (get-rbt xs) @$\rightarrow$@ Any P xs +data Any (P : !$\mathbb{N}$! !$\rightarrow$! Set) : rbt !$\rightarrow$! Set where + here : !$\forall$! {x : !$\mathbb{N}$!} {xs : rbt} !$\rightarrow$! P x !$\rightarrow$! Any P xs + there : !$\forall$! {x : !$\mathbb{N}$!} {xs : rbt} !$\rightarrow$! Any P (get-rbt xs) !$\rightarrow$! Any P xs -_∈_ : @$\forall$@ (n : @$\mathbb{N}$@) (xs : rbt) @$\rightarrow$@ Bool +_∈_ : !$\forall$! (n : !$\mathbb{N}$!) (xs : rbt) !$\rightarrow$! Bool n ∈ bt-empty = false n ∈ bt-node node with <-cmp n (node.number (tree.key node)) -... | tri< a @$\neg$@b @$\neg$@c = n ∈ (tree.ltree node) -... | tri≈ @$\neg$@a b @$\neg$@c = true -... | tri> @$\neg$@a @$\neg$@b c = n ∈ (tree.rtree node) +... | tri< a !$\neg$!b !$\neg$!c = n ∈ (tree.ltree node) +... | tri!$\approx$! !$\neg$!a b !$\neg$!c = true +... | tri> !$\neg$!a !$\neg$!b c = n ∈ (tree.rtree node) -testany1 : rbt @$\rightarrow$@ Set +testany1 : rbt !$\rightarrow$! Set testany1 bt-empty = {!!} testany1 (bt-node record { key = key ; ltree = ltree ; rtree = rtree }) = {!!} -testrbt1 = whileTestPCall' bt-empty 0 -testrbt2 = whileTestPCall' (Env.vart testrbt1) 1 -testrbt3 = whileTestPCall' (Env.vart testrbt2) 2 -testrbt4 = whileTestPCall' (Env.vart testrbt3) 3 -testrbt5 = whileTestPCall' (Env.vart testrbt4) 4 -testrbt6 = whileTestPCall' (Env.vart testrbt5) 5 -testrbt7 = whileTestPCall' (Env.vart testrbt6) 6 +testrbt1 = whileTestPCall!$\prime$! bt-empty 0 +testrbt2 = whileTestPCall!$\prime$! (Env.vart testrbt1) 1 +testrbt3 = whileTestPCall!$\prime$! (Env.vart testrbt2) 2 +testrbt4 = whileTestPCall!$\prime$! (Env.vart testrbt3) 3 +testrbt5 = whileTestPCall!$\prime$! (Env.vart testrbt4) 4 +testrbt6 = whileTestPCall!$\prime$! (Env.vart testrbt5) 5 +testrbt7 = whileTestPCall!$\prime$! (Env.vart testrbt6) 6 test1kk = 100 ∈ (Env.vart testrbt6) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/logic.agda.replaced --- a/Paper/src/agda/logic.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/logic.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -10,142 +10,142 @@ true : Bool false : Bool -record _@$\wedge$@_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n @$\sqcup$@ m) where +record _!$\wedge$!_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n !$\sqcup$! m) where field proj1 : A proj2 : B -data _∨_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n @$\sqcup$@ m) where - case1 : A @$\rightarrow$@ A ∨ B - case2 : B @$\rightarrow$@ A ∨ B +data _∨_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n !$\sqcup$! m) where + case1 : A !$\rightarrow$! A ∨ B + case2 : B !$\rightarrow$! A ∨ B -_⇔_ : {n m : Level } @$\rightarrow$@ ( A : Set n ) ( B : Set m ) @$\rightarrow$@ Set (n @$\sqcup$@ m) -_⇔_ A B = ( A @$\rightarrow$@ B ) @$\wedge$@ ( B @$\rightarrow$@ A ) +_⇔_ : {n m : Level } !$\rightarrow$! ( A : Set n ) ( B : Set m ) !$\rightarrow$! Set (n !$\sqcup$! m) +_⇔_ A B = ( A !$\rightarrow$! B ) !$\wedge$! ( B !$\rightarrow$! A ) -contra-position : {n m : Level } {A : Set n} {B : Set m} @$\rightarrow$@ (A @$\rightarrow$@ B) @$\rightarrow$@ @$\neg$@ B @$\rightarrow$@ @$\neg$@ A -contra-position {n} {m} {A} {B} f @$\neg$@b a = @$\neg$@b ( f a ) +contra-position : {n m : Level } {A : Set n} {B : Set m} !$\rightarrow$! (A !$\rightarrow$! B) !$\rightarrow$! !$\neg$! B !$\rightarrow$! !$\neg$! A +contra-position {n} {m} {A} {B} f !$\neg$!b a = !$\neg$!b ( f a ) -double-neg : {n : Level } {A : Set n} @$\rightarrow$@ A @$\rightarrow$@ @$\neg$@ @$\neg$@ A +double-neg : {n : Level } {A : Set n} !$\rightarrow$! A !$\rightarrow$! !$\neg$! !$\neg$! A double-neg A notnot = notnot A -double-neg2 : {n : Level } {A : Set n} @$\rightarrow$@ @$\neg$@ @$\neg$@ @$\neg$@ A @$\rightarrow$@ @$\neg$@ A +double-neg2 : {n : Level } {A : Set n} !$\rightarrow$! !$\neg$! !$\neg$! !$\neg$! A !$\rightarrow$! !$\neg$! A double-neg2 notnot A = notnot ( double-neg A ) -de-morgan : {n : Level } {A B : Set n} @$\rightarrow$@ A @$\wedge$@ B @$\rightarrow$@ @$\neg$@ ( (@$\neg$@ A ) ∨ (@$\neg$@ B ) ) -de-morgan {n} {A} {B} and (case1 @$\neg$@A) = @$\bot$@-elim ( @$\neg$@A ( _@$\wedge$@_.proj1 and )) -de-morgan {n} {A} {B} and (case2 @$\neg$@B) = @$\bot$@-elim ( @$\neg$@B ( _@$\wedge$@_.proj2 and )) +de-morgan : {n : Level } {A B : Set n} !$\rightarrow$! A !$\wedge$! B !$\rightarrow$! !$\neg$! ( (!$\neg$! A ) ∨ (!$\neg$! B ) ) +de-morgan {n} {A} {B} and (case1 !$\neg$!A) = !$\bot$!-elim ( !$\neg$!A ( _!$\wedge$!_.proj1 and )) +de-morgan {n} {A} {B} and (case2 !$\neg$!B) = !$\bot$!-elim ( !$\neg$!B ( _!$\wedge$!_.proj2 and )) -dont-or : {n m : Level} {A : Set n} { B : Set m } @$\rightarrow$@ A ∨ B @$\rightarrow$@ @$\neg$@ A @$\rightarrow$@ B -dont-or {A} {B} (case1 a) @$\neg$@A = @$\bot$@-elim ( @$\neg$@A a ) -dont-or {A} {B} (case2 b) @$\neg$@A = b +dont-or : {n m : Level} {A : Set n} { B : Set m } !$\rightarrow$! A ∨ B !$\rightarrow$! !$\neg$! A !$\rightarrow$! B +dont-or {A} {B} (case1 a) !$\neg$!A = !$\bot$!-elim ( !$\neg$!A a ) +dont-or {A} {B} (case2 b) !$\neg$!A = b -dont-orb : {n m : Level} {A : Set n} { B : Set m } @$\rightarrow$@ A ∨ B @$\rightarrow$@ @$\neg$@ B @$\rightarrow$@ A -dont-orb {A} {B} (case2 b) @$\neg$@B = @$\bot$@-elim ( @$\neg$@B b ) -dont-orb {A} {B} (case1 a) @$\neg$@B = a +dont-orb : {n m : Level} {A : Set n} { B : Set m } !$\rightarrow$! A ∨ B !$\rightarrow$! !$\neg$! B !$\rightarrow$! A +dont-orb {A} {B} (case2 b) !$\neg$!B = !$\bot$!-elim ( !$\neg$!B b ) +dont-orb {A} {B} (case1 a) !$\neg$!B = a -infixr 130 _@$\wedge$@_ +infixr 130 _!$\wedge$!_ infixr 140 _∨_ infixr 150 _⇔_ -_@$\wedge$@_ : Bool @$\rightarrow$@ Bool @$\rightarrow$@ Bool -true @$\wedge$@ true = true -_ @$\wedge$@ _ = false +_!$\wedge$!_ : Bool !$\rightarrow$! Bool !$\rightarrow$! Bool +true !$\wedge$! true = true +_ !$\wedge$! _ = false -_\/_ : Bool @$\rightarrow$@ Bool @$\rightarrow$@ Bool +_\/_ : Bool !$\rightarrow$! Bool !$\rightarrow$! Bool false \/ false = false _ \/ _ = true -not_ : Bool @$\rightarrow$@ Bool +not_ : Bool !$\rightarrow$! Bool not true = false not false = true -_<=>_ : Bool @$\rightarrow$@ Bool @$\rightarrow$@ Bool +_<=>_ : Bool !$\rightarrow$! Bool !$\rightarrow$! Bool true <=> true = true false <=> false = true _ <=> _ = false infixr 130 _\/_ -infixr 140 _@$\wedge$@_ +infixr 140 _!$\wedge$!_ open import Relation.Binary.PropositionalEquality -@$\equiv$@-Bool-func : {A B : Bool } @$\rightarrow$@ ( A @$\equiv$@ true @$\rightarrow$@ B @$\equiv$@ true ) @$\rightarrow$@ ( B @$\equiv$@ true @$\rightarrow$@ A @$\equiv$@ true ) @$\rightarrow$@ A @$\equiv$@ B -@$\equiv$@-Bool-func {true} {true} a@$\rightarrow$@b b@$\rightarrow$@a = refl -@$\equiv$@-Bool-func {false} {true} a@$\rightarrow$@b b@$\rightarrow$@a with b@$\rightarrow$@a refl +!$\equiv$!-Bool-func : {A B : Bool } !$\rightarrow$! ( A !$\equiv$! true !$\rightarrow$! B !$\equiv$! true ) !$\rightarrow$! ( B !$\equiv$! true !$\rightarrow$! A !$\equiv$! true ) !$\rightarrow$! A !$\equiv$! B +!$\equiv$!-Bool-func {true} {true} a!$\rightarrow$!b b!$\rightarrow$!a = refl +!$\equiv$!-Bool-func {false} {true} a!$\rightarrow$!b b!$\rightarrow$!a with b!$\rightarrow$!a refl ... | () -@$\equiv$@-Bool-func {true} {false} a@$\rightarrow$@b b@$\rightarrow$@a with a@$\rightarrow$@b refl +!$\equiv$!-Bool-func {true} {false} a!$\rightarrow$!b b!$\rightarrow$!a with a!$\rightarrow$!b refl ... | () -@$\equiv$@-Bool-func {false} {false} a@$\rightarrow$@b b@$\rightarrow$@a = refl +!$\equiv$!-Bool-func {false} {false} a!$\rightarrow$!b b!$\rightarrow$!a = refl -bool-@$\equiv$@-? : (a b : Bool) @$\rightarrow$@ Dec ( a @$\equiv$@ b ) -bool-@$\equiv$@-? true true = yes refl -bool-@$\equiv$@-? true false = no (@$\lambda$@ ()) -bool-@$\equiv$@-? false true = no (@$\lambda$@ ()) -bool-@$\equiv$@-? false false = yes refl +bool-!$\equiv$!-? : (a b : Bool) !$\rightarrow$! Dec ( a !$\equiv$! b ) +bool-!$\equiv$!-? true true = yes refl +bool-!$\equiv$!-? true false = no (!$\lambda$! ()) +bool-!$\equiv$!-? false true = no (!$\lambda$! ()) +bool-!$\equiv$!-? false false = yes refl -@$\neg$@-bool-t : {a : Bool} @$\rightarrow$@ @$\neg$@ ( a @$\equiv$@ true ) @$\rightarrow$@ a @$\equiv$@ false -@$\neg$@-bool-t {true} ne = @$\bot$@-elim ( ne refl ) -@$\neg$@-bool-t {false} ne = refl +!$\neg$!-bool-t : {a : Bool} !$\rightarrow$! !$\neg$! ( a !$\equiv$! true ) !$\rightarrow$! a !$\equiv$! false +!$\neg$!-bool-t {true} ne = !$\bot$!-elim ( ne refl ) +!$\neg$!-bool-t {false} ne = refl -@$\neg$@-bool-f : {a : Bool} @$\rightarrow$@ @$\neg$@ ( a @$\equiv$@ false ) @$\rightarrow$@ a @$\equiv$@ true -@$\neg$@-bool-f {true} ne = refl -@$\neg$@-bool-f {false} ne = @$\bot$@-elim ( ne refl ) +!$\neg$!-bool-f : {a : Bool} !$\rightarrow$! !$\neg$! ( a !$\equiv$! false ) !$\rightarrow$! a !$\equiv$! true +!$\neg$!-bool-f {true} ne = refl +!$\neg$!-bool-f {false} ne = !$\bot$!-elim ( ne refl ) -@$\neg$@-bool : {a : Bool} @$\rightarrow$@ a @$\equiv$@ false @$\rightarrow$@ a @$\equiv$@ true @$\rightarrow$@ @$\bot$@ -@$\neg$@-bool refl () +!$\neg$!-bool : {a : Bool} !$\rightarrow$! a !$\equiv$! false !$\rightarrow$! a !$\equiv$! true !$\rightarrow$! !$\bot$! +!$\neg$!-bool refl () -lemma-@$\wedge$@-0 : {a b : Bool} @$\rightarrow$@ a @$\wedge$@ b @$\equiv$@ true @$\rightarrow$@ a @$\equiv$@ false @$\rightarrow$@ @$\bot$@ -lemma-@$\wedge$@-0 {true} {true} refl () -lemma-@$\wedge$@-0 {true} {false} () -lemma-@$\wedge$@-0 {false} {true} () -lemma-@$\wedge$@-0 {false} {false} () +lemma-!$\wedge$!-0 : {a b : Bool} !$\rightarrow$! a !$\wedge$! b !$\equiv$! true !$\rightarrow$! a !$\equiv$! false !$\rightarrow$! !$\bot$! +lemma-!$\wedge$!-0 {true} {true} refl () +lemma-!$\wedge$!-0 {true} {false} () +lemma-!$\wedge$!-0 {false} {true} () +lemma-!$\wedge$!-0 {false} {false} () -lemma-@$\wedge$@-1 : {a b : Bool} @$\rightarrow$@ a @$\wedge$@ b @$\equiv$@ true @$\rightarrow$@ b @$\equiv$@ false @$\rightarrow$@ @$\bot$@ -lemma-@$\wedge$@-1 {true} {true} refl () -lemma-@$\wedge$@-1 {true} {false} () -lemma-@$\wedge$@-1 {false} {true} () -lemma-@$\wedge$@-1 {false} {false} () +lemma-!$\wedge$!-1 : {a b : Bool} !$\rightarrow$! a !$\wedge$! b !$\equiv$! true !$\rightarrow$! b !$\equiv$! false !$\rightarrow$! !$\bot$! +lemma-!$\wedge$!-1 {true} {true} refl () +lemma-!$\wedge$!-1 {true} {false} () +lemma-!$\wedge$!-1 {false} {true} () +lemma-!$\wedge$!-1 {false} {false} () -bool-and-tt : {a b : Bool} @$\rightarrow$@ a @$\equiv$@ true @$\rightarrow$@ b @$\equiv$@ true @$\rightarrow$@ ( a @$\wedge$@ b ) @$\equiv$@ true +bool-and-tt : {a b : Bool} !$\rightarrow$! a !$\equiv$! true !$\rightarrow$! b !$\equiv$! true !$\rightarrow$! ( a !$\wedge$! b ) !$\equiv$! true bool-and-tt refl refl = refl -bool-@$\wedge$@@$\rightarrow$@tt-0 : {a b : Bool} @$\rightarrow$@ ( a @$\wedge$@ b ) @$\equiv$@ true @$\rightarrow$@ a @$\equiv$@ true -bool-@$\wedge$@@$\rightarrow$@tt-0 {true} {true} refl = refl -bool-@$\wedge$@@$\rightarrow$@tt-0 {false} {_} () +bool-!$\wedge$!!$\rightarrow$!tt-0 : {a b : Bool} !$\rightarrow$! ( a !$\wedge$! b ) !$\equiv$! true !$\rightarrow$! a !$\equiv$! true +bool-!$\wedge$!!$\rightarrow$!tt-0 {true} {true} refl = refl +bool-!$\wedge$!!$\rightarrow$!tt-0 {false} {_} () -bool-@$\wedge$@@$\rightarrow$@tt-1 : {a b : Bool} @$\rightarrow$@ ( a @$\wedge$@ b ) @$\equiv$@ true @$\rightarrow$@ b @$\equiv$@ true -bool-@$\wedge$@@$\rightarrow$@tt-1 {true} {true} refl = refl -bool-@$\wedge$@@$\rightarrow$@tt-1 {true} {false} () -bool-@$\wedge$@@$\rightarrow$@tt-1 {false} {false} () +bool-!$\wedge$!!$\rightarrow$!tt-1 : {a b : Bool} !$\rightarrow$! ( a !$\wedge$! b ) !$\equiv$! true !$\rightarrow$! b !$\equiv$! true +bool-!$\wedge$!!$\rightarrow$!tt-1 {true} {true} refl = refl +bool-!$\wedge$!!$\rightarrow$!tt-1 {true} {false} () +bool-!$\wedge$!!$\rightarrow$!tt-1 {false} {false} () -bool-or-1 : {a b : Bool} @$\rightarrow$@ a @$\equiv$@ false @$\rightarrow$@ ( a \/ b ) @$\equiv$@ b +bool-or-1 : {a b : Bool} !$\rightarrow$! a !$\equiv$! false !$\rightarrow$! ( a \/ b ) !$\equiv$! b bool-or-1 {false} {true} refl = refl bool-or-1 {false} {false} refl = refl -bool-or-2 : {a b : Bool} @$\rightarrow$@ b @$\equiv$@ false @$\rightarrow$@ (a \/ b ) @$\equiv$@ a +bool-or-2 : {a b : Bool} !$\rightarrow$! b !$\equiv$! false !$\rightarrow$! (a \/ b ) !$\equiv$! a bool-or-2 {true} {false} refl = refl bool-or-2 {false} {false} refl = refl -bool-or-3 : {a : Bool} @$\rightarrow$@ ( a \/ true ) @$\equiv$@ true +bool-or-3 : {a : Bool} !$\rightarrow$! ( a \/ true ) !$\equiv$! true bool-or-3 {true} = refl bool-or-3 {false} = refl -bool-or-31 : {a b : Bool} @$\rightarrow$@ b @$\equiv$@ true @$\rightarrow$@ ( a \/ b ) @$\equiv$@ true +bool-or-31 : {a b : Bool} !$\rightarrow$! b !$\equiv$! true !$\rightarrow$! ( a \/ b ) !$\equiv$! true bool-or-31 {true} {true} refl = refl bool-or-31 {false} {true} refl = refl -bool-or-4 : {a : Bool} @$\rightarrow$@ ( true \/ a ) @$\equiv$@ true +bool-or-4 : {a : Bool} !$\rightarrow$! ( true \/ a ) !$\equiv$! true bool-or-4 {true} = refl bool-or-4 {false} = refl -bool-or-41 : {a b : Bool} @$\rightarrow$@ a @$\equiv$@ true @$\rightarrow$@ ( a \/ b ) @$\equiv$@ true +bool-or-41 : {a b : Bool} !$\rightarrow$! a !$\equiv$! true !$\rightarrow$! ( a \/ b ) !$\equiv$! true bool-or-41 {true} {b} refl = refl -bool-and-1 : {a b : Bool} @$\rightarrow$@ a @$\equiv$@ false @$\rightarrow$@ (a @$\wedge$@ b ) @$\equiv$@ false +bool-and-1 : {a b : Bool} !$\rightarrow$! a !$\equiv$! false !$\rightarrow$! (a !$\wedge$! b ) !$\equiv$! false bool-and-1 {false} {b} refl = refl -bool-and-2 : {a b : Bool} @$\rightarrow$@ b @$\equiv$@ false @$\rightarrow$@ (a @$\wedge$@ b ) @$\equiv$@ false +bool-and-2 : {a b : Bool} !$\rightarrow$! b !$\equiv$! false !$\rightarrow$! (a !$\wedge$! b ) !$\equiv$! false bool-and-2 {true} {false} refl = refl bool-and-2 {false} {false} refl = refl diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/plus.agda.replaced --- a/Paper/src/agda/plus.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/plus.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -plus : (x y : @$\mathbb{N}$@) @$\rightarrow$@ @$\mathbb{N}$@ +plus : (x y : !$\mathbb{N}$!) !$\rightarrow$! !$\mathbb{N}$! plus x zero = x plus x (suc y) = plus (suc x) y diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/plus2.agda.replaced --- a/Paper/src/agda/plus2.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/plus2.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -2,7 +2,7 @@ open import Data.Nat hiding (_+_) -_+_ : (x y : @$\mathbb{N}$@) @$\rightarrow$@ @$\mathbb{N}$@ +_+_ : (x y : !$\mathbb{N}$!) !$\rightarrow$! !$\mathbb{N}$! x + zero = x x + suc y = (suc x) + y diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/rbt_imple.agda.replaced --- a/Paper/src/agda/rbt_imple.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/rbt_imple.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -2,7 +2,7 @@ open import Level renaming ( suc to succ ; zero to Zero ) open import Relation.Binary -open import Data.Nat hiding (_@$\leq$@_ ; _@$\leq$@?_) +open import Data.Nat hiding (_!$\leq$!_ ; _!$\leq$!?_) open import Data.List hiding ([_]) open import Data.Product open import Data.Nat.Properties as NP @@ -13,49 +13,49 @@ mutual data right-List : Set where [] : right-List - [_] : @$\mathbb{N}$@ @$\rightarrow$@ right-List - _@$\text{::}$@>_Cond_ : (x : @$\mathbb{N}$@) @$\rightarrow$@ (xs : right-List ) @$\rightarrow$@ (p : x Data.Nat.> top-r xs) @$\rightarrow$@ right-List + [_] : !$\mathbb{N}$! !$\rightarrow$! right-List + _!$\text{::}$!>_Cond_ : (x : !$\mathbb{N}$!) !$\rightarrow$! (xs : right-List ) !$\rightarrow$! (p : x Data.Nat.> top-r xs) !$\rightarrow$! right-List - top-r : right-List @$\rightarrow$@ @$\mathbb{N}$@ + top-r : right-List !$\rightarrow$! !$\mathbb{N}$! top-r [] = {!!} top-r [ x ] = x - top-r (x @$\text{::}$@> l Cond x@$\_{1}$@) = x + top-r (x !$\text{::}$!> l Cond x!$\_{1}$!) = x - insert-r : @$\mathbb{N}$@ @$\rightarrow$@ right-List @$\rightarrow$@ right-List + insert-r : !$\mathbb{N}$! !$\rightarrow$! right-List !$\rightarrow$! right-List insert-r x l with l ... | [] = {!!} ... | [ y ] = ? - ... | y @$\text{::}$@> ys Cond p with <-cmp x y - ... | tri< a @$\neg$@b @$\neg$@c = l - ... | tri≈ @$\neg$@a b @$\neg$@c = l - ... | tri> @$\neg$@a @$\neg$@b c = x @$\text{::}$@> l Cond c + ... | y !$\text{::}$!> ys Cond p with <-cmp x y + ... | tri< a !$\neg$!b !$\neg$!c = l + ... | tri!$\approx$! !$\neg$!a b !$\neg$!c = l + ... | tri> !$\neg$!a !$\neg$!b c = x !$\text{::}$!> l Cond c data left-List : Set where [] : left-List - [_] : @$\mathbb{N}$@ @$\rightarrow$@ left-List - _<@$\text{::}$@_Cond_ : (x : @$\mathbb{N}$@) @$\rightarrow$@ (xs : left-List ) @$\rightarrow$@ (p : x Data.Nat.< top-l xs) @$\rightarrow$@ left-List + [_] : !$\mathbb{N}$! !$\rightarrow$! left-List + _ @$\neg$@a @$\neg$@b c = l - insert-l x l@(y <@$\text{::}$@ ys Cond p) with <-cmp x y - ... | tri< a @$\neg$@b @$\neg$@c = x <@$\text{::}$@ l Cond a - ... | tri≈ @$\neg$@a b @$\neg$@c = l - ... | tri> @$\neg$@a @$\neg$@b c = l + ... | tri< a !$\neg$!b !$\neg$!c = x !$\neg$!a !$\neg$!b c = l + insert-l x l@(y !$\neg$!a !$\neg$!b c = l record meta : Set where field - deeps : @$\mathbb{N}$@ - black-nodes : @$\mathbb{N}$@ + deeps : !$\mathbb{N}$! + black-nodes : !$\mathbb{N}$! l-list : left-List r-list : right-List open meta @@ -72,36 +72,36 @@ data rbt-meta : Set where bt-empty : rbt-meta - bt-node : (node : tree-meta (node col @$\mathbb{N}$@ ) meta rbt-meta rbt-meta ) @$\rightarrow$@ rbt-meta + bt-node : (node : tree-meta (node col !$\mathbb{N}$! ) meta rbt-meta rbt-meta ) !$\rightarrow$! rbt-meta -test'1 = whileTestPCall' bt-empty 0 -test'2 = whileTestPCall' (rbt_t.Env.vart test'1) 1 -test'3 = whileTestPCall' (rbt_t.Env.vart test'2) 2 -test'4 = whileTestPCall' (rbt_t.Env.vart test'3) 3 -test'5 = whileTestPCall' (rbt_t.Env.vart test'4) 4 -test'6 = whileTestPCall' (rbt_t.Env.vart test'5) 5 -test'7 = whileTestPCall' (rbt_t.Env.vart test'6) 6 -test'8 = whileTestPCall' (rbt_t.Env.vart test'7) 7 -test'9 = whileTestPCall' (rbt_t.Env.vart test'8) 8 -test'10 = whileTestPCall' (rbt_t.Env.vart test'9) 9 -test'11 = whileTestPCall' (rbt_t.Env.vart test'10) 10 -test'12 = whileTestPCall' (rbt_t.Env.vart test'11) 11 -test'13 = whileTestPCall' (rbt_t.Env.vart test'12) 12 -test'14 = whileTestPCall' (rbt_t.Env.vart test'13) 13 -test'15 = whileTestPCall' (rbt_t.Env.vart test'14) 14 +test!$\prime$!1 = whileTestPCall!$\prime$! bt-empty 0 +test!$\prime$!2 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!1) 1 +test!$\prime$!3 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!2) 2 +test!$\prime$!4 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!3) 3 +test!$\prime$!5 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!4) 4 +test!$\prime$!6 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!5) 5 +test!$\prime$!7 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!6) 6 +test!$\prime$!8 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!7) 7 +test!$\prime$!9 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!8) 8 +test!$\prime$!10 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!9) 9 +test!$\prime$!11 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!10) 10 +test!$\prime$!12 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!11) 11 +test!$\prime$!13 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!12) 12 +test!$\prime$!14 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!13) 13 +test!$\prime$!15 = whileTestPCall!$\prime$! (rbt_t.Env.vart test!$\prime$!14) 14 -testdata = rbt_t.Env.vart test'7 +testdata = rbt_t.Env.vart test!$\prime$!7 -- ここからmetaの作成 -makemeta-comm : rbt_t.rbt @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ meta @$\rightarrow$@ rbt-meta +makemeta-comm : rbt_t.rbt !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! meta !$\rightarrow$! rbt-meta --make meta black nodes -makemeta-black-nodes : rbt_t.rbt @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ meta @$\rightarrow$@ rbt-meta +makemeta-black-nodes : rbt_t.rbt !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! meta !$\rightarrow$! rbt-meta makemeta-black-nodes = {!!} -- make meta deeps -set-black-nodes : rbt_t.rbt @$\rightarrow$@ meta @$\rightarrow$@ @$\mathbb{N}$@ +set-black-nodes : rbt_t.rbt !$\rightarrow$! meta !$\rightarrow$! !$\mathbb{N}$! set-black-nodes rbt fls with rbt ... | bt-empty = (suc (black-nodes fls) ) ... | bt-node node with (node.coler (key node)) @@ -126,7 +126,7 @@ ; r-list = insert-r (node.number (key node)) (r-list fls) } ) }) -- init -makemeta : rbt @$\rightarrow$@ rbt-meta +makemeta : rbt !$\rightarrow$! rbt-meta makemeta rbt with rbt ... | bt-empty = bt-empty ... | bt-node node = bt-node ( record { key = key node @@ -136,5 +136,5 @@ ; rtree = makemeta-comm (rtree node) (node.number (key node)) ( record { deeps = 1 ; black-nodes = 1 ; l-list = [] ; r-list = insert-r (node.number (key node)) [] } ) }) ----test11 = makemeta (rbt_t.Env.vart test'11) +---test11 = makemeta (rbt_t.Env.vart test!$\prime$!11) -} diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/rbt_t.agda.replaced --- a/Paper/src/agda/rbt_t.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/rbt_t.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -5,7 +5,7 @@ open import Relation.Binary open import Data.List --- @$\rightarrow$@ t を適用するために必要だった +-- !$\rightarrow$! t を適用するために必要だった open import Level renaming ( suc to succ ; zero to Zero ) open import Level @@ -29,31 +29,31 @@ data rbt : Set where bt-empty : rbt - bt-node : (node : tree (node col @$\mathbb{N}$@) rbt rbt ) @$\rightarrow$@ rbt + bt-node : (node : tree (node col !$\mathbb{N}$!) rbt rbt ) !$\rightarrow$! rbt record Env : Set (succ Zero) where field vart : rbt - varn : @$\mathbb{N}$@ + varn : !$\mathbb{N}$! varl : List rbt open Env -whileTest-next : {l : Level} {t : Set l} @$\rightarrow$@ (c10 : rbt) @$\rightarrow$@ (n : @$\mathbb{N}$@) @$\rightarrow$@ (list : List rbt) @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +whileTest-next : {l : Level} {t : Set l} !$\rightarrow$! (c10 : rbt) !$\rightarrow$! (n : !$\mathbb{N}$!) !$\rightarrow$! (list : List rbt) !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t whileTest-next c10 n list next exit = next (record {vart = c10 ; varn = n ; varl = list} ) -merge-tree : {le : Level} {t : Set le} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +merge-tree : {le : Level} {t : Set le} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t -- 全てmerge-treeへ -split : {le : Level} {t : Set le} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +split : {le : Level} {t : Set le} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t split node@record { vart = bt-empty ; varn = varn ; varl = varl } next exit = exit node split node@record { vart = (bt-node record { key = key ; ltree = bt-empty ; rtree = rtree }) ; varn = varn ; varl = varl } next exit = exit node -split node@record { vart = (bt-node record { key = key ; ltree = (bt-node node@$\_{1}$@) ; rtree = bt-empty }) ; varn = varn ; varl = varl } next exit = exit node -split record { vart = (bt-node record { key = record { coler = coler@$\_{1}$@ ; number = number@$\_{1}$@ } +split node@record { vart = (bt-node record { key = key ; ltree = (bt-node node!$\_{1}$!) ; rtree = bt-empty }) ; varn = varn ; varl = varl } next exit = exit node +split record { vart = (bt-node record { key = record { coler = coler!$\_{1}$! ; number = number!$\_{1}$! } ; ltree = (bt-node record { key = record { coler = ly ; number = ln } ; ltree = ll ; rtree = lr }) ; rtree = (bt-node record { key = record { coler = ry ; number = rn } ; ltree = rl ; rtree = rr }) }) ; varn = varn ; varl = varl } next exit - = next record { vart = (bt-node record { key = record { coler = red ; number = number@$\_{1}$@ } + = next record { vart = (bt-node record { key = record { coler = red ; number = number!$\_{1}$! } ; ltree = (bt-node record { key = record { coler = black ; number = ln } ; ltree = ll ; rtree = lr }) ; rtree = (bt-node record { key = record { coler = black ; number = rn } ; ltree = rl ; rtree = rr }) }) ; varn = varn ; varl = varl } @@ -61,7 +61,7 @@ -- 右回転 -- 実行時splitへ、それ以外はmerge-treeへ -merge-rotate-right : {le : Level} {t : Set le} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +merge-rotate-right : {le : Level} {t : Set le} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t merge-rotate-right node@record { vart = bt-empty ; varn = varn ; varl = varl } next exit = exit node merge-rotate-right node@record { vart = bt-node record { key = record { coler = coler ; number = number } ; ltree = bt-empty ; rtree = r } ; varn = varn ; varl = varl } next exit = exit node merge-rotate-right record { vart = bt-node record { key = record { coler = y ; number = x } @@ -75,15 +75,15 @@ -- split -split-branch : {le : Level} {t : Set le} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +split-branch : {le : Level} {t : Set le} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t split-branch node@record{ vart = bt-empty ; varn = varn ; varl = varl } next exit = exit node split-branch node@record{ vart = bt-node record { key = key ; ltree = bt-empty ; rtree = rtree } ; varn = varn ; varl = varl } next exit = exit node -split-branch node@record{ vart = bt-node record { key = key@$\_{1}$@ ; ltree = (bt-node record { key = record { coler = lc ; number = number } ; ltree = bt-empty ; rtree = lr }) ; rtree = rtree } ; varn = varn ; varl = varl } next exit = exit node -split-branch node@record{ vart = bt-node record { key = key@$\_{1}$@ ; ltree = (bt-node record { key = record { coler = black ; number = number } ; ltree = (bt-node node@$\_{1}$@) ; rtree = lr }) ; rtree = rtree } ; varn = varn ; varl = varl } next exit = exit node -split-branch node@record{ vart = bt-node record { key = key@$\_{1}$@ ; ltree = (bt-node record { key = record { coler = red ; number = number@$\_{1}$@ } ; ltree = (bt-node record { key = record { coler = black ; number = number } ; ltree = ltree ; rtree = rtree@$\_{1}$@ }) ; rtree = lr }) ; rtree = rtree } ; varn = varn ; varl = varl } next exit = exit node -split-branch node@record{ vart = bt-node record { key = key@$\_{1}$@ - ; ltree = (bt-node record { key = record { coler = red ; number = number@$\_{1}$@ } - ; ltree = (bt-node record { key = record { coler = red ; number = number } ; ltree = ltree ; rtree = rtree@$\_{1}$@ }) +split-branch node@record{ vart = bt-node record { key = key!$\_{1}$! ; ltree = (bt-node record { key = record { coler = lc ; number = number } ; ltree = bt-empty ; rtree = lr }) ; rtree = rtree } ; varn = varn ; varl = varl } next exit = exit node +split-branch node@record{ vart = bt-node record { key = key!$\_{1}$! ; ltree = (bt-node record { key = record { coler = black ; number = number } ; ltree = (bt-node node!$\_{1}$!) ; rtree = lr }) ; rtree = rtree } ; varn = varn ; varl = varl } next exit = exit node +split-branch node@record{ vart = bt-node record { key = key!$\_{1}$! ; ltree = (bt-node record { key = record { coler = red ; number = number!$\_{1}$! } ; ltree = (bt-node record { key = record { coler = black ; number = number } ; ltree = ltree ; rtree = rtree!$\_{1}$! }) ; rtree = lr }) ; rtree = rtree } ; varn = varn ; varl = varl } next exit = exit node +split-branch node@record{ vart = bt-node record { key = key!$\_{1}$! + ; ltree = (bt-node record { key = record { coler = red ; number = number!$\_{1}$! } + ; ltree = (bt-node record { key = record { coler = red ; number = number } ; ltree = ltree ; rtree = rtree!$\_{1}$! }) ; rtree = lr }) ; rtree = rtree } ; varn = varn ; varl = varl } next exit @@ -91,7 +91,7 @@ -- 左回転、exitはsplit_branchへ nextもsplit_branchへ -merge-rotate-left : {le : Level} {t : Set le} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +merge-rotate-left : {le : Level} {t : Set le} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t merge-rotate-left node@record { vart = bt-empty ; varn = varn ; varl = varl } next exit = exit node merge-rotate-left node@record { vart = bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = bt-empty } ; varn = varn ; varl = varl } next exit = exit node merge-rotate-left record { vart = bt-node record { key = record { coler = y ; number = x } ; ltree = l ; rtree = (bt-node record { key = record { coler = ry ; number = rx } ; ltree = rl ; rtree = rr }) } ; varn = varn ; varl = varl } next exit @@ -102,182 +102,182 @@ -- skew exitがsplitへ nextが左回転 -skew-bt : {le : Level} {t : Set le} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +skew-bt : {le : Level} {t : Set le} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t skew-bt node@record { vart = bt-empty ; varn = varn ; varl = varl } next exit = exit node skew-bt node@record { vart = (bt-node record { key = key ; ltree = ltree ; rtree = bt-empty }) ; varn = varn ; varl = varl } next exit = exit node -skew-bt node@record { vart = (bt-node record { key = key@$\_{1}$@ - ; ltree = ltree@$\_{1}$@ +skew-bt node@record { vart = (bt-node record { key = key!$\_{1}$! + ; ltree = ltree!$\_{1}$! ; rtree = (bt-node record { key = record { coler = black ; number = number } ; ltree = ltree ; rtree = rtree }) }) ; varn = varn ; varl = varl } next exit = exit node -skew-bt node@record { vart = (bt-node record { key = key@$\_{1}$@ - ; ltree = ltree@$\_{1}$@ +skew-bt node@record { vart = (bt-node record { key = key!$\_{1}$! + ; ltree = ltree!$\_{1}$! ; rtree = (bt-node record { key = record { coler = red ; number = number } ; ltree = ltree ; rtree = rtree }) }) ; varn = varn ; varl = varl } next exit = next node -set-node-coler : Env @$\rightarrow$@ Env +set-node-coler : Env !$\rightarrow$! Env set-node-coler node@record { vart = bt-empty ; varn = varn ; varl = varl } = node set-node-coler record { vart = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree }) ; varn = varn ; varl = varl } = record { vart = (bt-node record { key = record { coler = black ; number = number } ; ltree = ltree ; rtree = rtree }) ; varn = varn ; varl = varl } -init-node-coler : {le : Level} {t : Set le} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +init-node-coler : {le : Level} {t : Set le} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t init-node-coler node@record { vart = bt-empty ; varn = varn ; varl = varl } next exit = exit node init-node-coler record { vart = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree }) ; varn = varn ; varl = varl } next exit = exit record { vart = (bt-node record { key = record { coler = black ; number = number } ; ltree = ltree ; rtree = rtree }) ; varn = varn ; varl = varl } --修正前 merge-tree node@record { vart = vart ; varn = varn ; varl = [] } next exit = exit node -merge-tree node@record { vart = vart ; varn = varn ; varl = (bt-empty @$\text{::}$@ varl@$\_{1}$@) } next exit = exit node +merge-tree node@record { vart = vart ; varn = varn ; varl = (bt-empty !$\text{::}$! varl!$\_{1}$!) } next exit = exit node -merge-tree record { vart = vart ; varn = varn ; varl = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree } @$\text{::}$@ varl@$\_{1}$@) } next exit with <-cmp varn number +merge-tree record { vart = vart ; varn = varn ; varl = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree } !$\text{::}$! varl!$\_{1}$!) } next exit with <-cmp varn number -merge-tree record { vart = vart ; varn = varn ; varl = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree } @$\text{::}$@ varl@$\_{1}$@) } next exit | tri≈ @$\neg$@a b @$\neg$@c - = next record { vart = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree }) ; varn = number ; varl = varl@$\_{1}$@ } +merge-tree record { vart = vart ; varn = varn ; varl = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree } !$\text{::}$! varl!$\_{1}$!) } next exit | tri!$\approx$! !$\neg$!a b !$\neg$!c + = next record { vart = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree }) ; varn = number ; varl = varl!$\_{1}$! } -merge-tree record { vart = vart ; varn = varn ; varl = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree } @$\text{::}$@ varl@$\_{1}$@) } next exit | tri> @$\neg$@a @$\neg$@b c - = next record { vart = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = vart }) ; varn = number ; varl = varl@$\_{1}$@ } +merge-tree record { vart = vart ; varn = varn ; varl = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree } !$\text{::}$! varl!$\_{1}$!) } next exit | tri> !$\neg$!a !$\neg$!b c + = next record { vart = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = vart }) ; varn = number ; varl = varl!$\_{1}$! } -merge-tree record { vart = vart ; varn = varn ; varl = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree } @$\text{::}$@ varl@$\_{1}$@) } next exit | tri< a @$\neg$@b @$\neg$@c - = next record { vart = (bt-node record { key = record { coler = coler ; number = number } ; ltree = vart ; rtree = rtree }) ; varn = number ; varl = varl@$\_{1}$@ } +merge-tree record { vart = vart ; varn = varn ; varl = (bt-node record { key = record { coler = coler ; number = number } ; ltree = ltree ; rtree = rtree } !$\text{::}$! varl!$\_{1}$!) } next exit | tri< a !$\neg$!b !$\neg$!c + = next record { vart = (bt-node record { key = record { coler = coler ; number = number } ; ltree = vart ; rtree = rtree }) ; varn = number ; varl = varl!$\_{1}$! } -- do marge-tree -- next merge-tree-c -- exit fin -merge-tree-c : {le : Level} {t : Set le} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +merge-tree-c : {le : Level} {t : Set le} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t merge-tree-c env next exit with varl env ... | [] = exit env -... | bt-empty @$\text{::}$@ nl = exit env -... | bt-node xtree @$\text{::}$@ varl with <-cmp (varn env) (number ( key xtree )) -... | tri≈ @$\neg$@a b @$\neg$@c = next (record env { vart = bt-node xtree ; varn = number (key xtree) ; varl = varl }) -... | tri> @$\neg$@a @$\neg$@b c = next (record env { vart = (bt-node record xtree{rtree = Env.vart env}) ; varn = number (key xtree) ; varl = varl }) -... | tri< a @$\neg$@b @$\neg$@c = next (record env { vart = (bt-node record xtree{ltree = Env.vart env}) ; varn = number (key xtree) ; varl = varl }) +... | bt-empty !$\text{::}$! nl = exit env +... | bt-node xtree !$\text{::}$! varl with <-cmp (varn env) (number ( key xtree )) +... | tri!$\approx$! !$\neg$!a b !$\neg$!c = next (record env { vart = bt-node xtree ; varn = number (key xtree) ; varl = varl }) +... | tri> !$\neg$!a !$\neg$!b c = next (record env { vart = (bt-node record xtree{rtree = Env.vart env}) ; varn = number (key xtree) ; varl = varl }) +... | tri< a !$\neg$!b !$\neg$!c = next (record env { vart = (bt-node record xtree{ltree = Env.vart env}) ; varn = number (key xtree) ; varl = varl }) -- do brandh -- next insert-c -- exit merge-tree -insert-c : {le : Level} {t : Set le} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +insert-c : {le : Level} {t : Set le} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t insert-c env next exit with Env.vart env ... | bt-empty = exit record env{vart = (bt-node (record { key = record { coler = red ; number = Env.varn env }; ltree = bt-empty; rtree = bt-empty }))} ... | bt-node node with <-cmp (Env.varn env) (node.number (tree.key node)) -... | tri≈ @$\neg$@a b @$\neg$@c = exit env -... | tri> @$\neg$@a @$\neg$@b c = next record env{vart = (tree.ltree node) ; varl = (bt-node record node{ltree = bt-empty}) @$\text{::}$@ (Env.varl env) } -... | tri< a @$\neg$@b @$\neg$@c = next record env{vart = (tree.rtree node) ; varl = (bt-node record node{rtree = bt-empty}) @$\text{::}$@ (Env.varl env) } +... | tri!$\approx$! !$\neg$!a b !$\neg$!c = exit env +... | tri> !$\neg$!a !$\neg$!b c = next record env{vart = (tree.ltree node) ; varl = (bt-node record node{ltree = bt-empty}) !$\text{::}$! (Env.varl env) } +... | tri< a !$\neg$!b !$\neg$!c = next record env{vart = (tree.rtree node) ; varl = (bt-node record node{rtree = bt-empty}) !$\text{::}$! (Env.varl env) } -- insert -bt-insert : {le : Level} {t : Set le} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +bt-insert : {le : Level} {t : Set le} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t -- mergeへ遷移する bt-insert (record { vart = bt-empty ; varn = varn ; varl = varl }) next exit = exit (record { vart = (bt-node (record { key = record { coler = red ; number = varn }; ltree = bt-empty; rtree = bt-empty })) ; varn = varn ; varl = varl }) -- 場合分けを行う bt-insert record {vart = (bt-node record { key = record { coler = y; number = x } ; ltree = ltree ; rtree = rtree }) ; varn = n ; varl = varl } next exit with <-cmp x n -bt-insert node@(record { vart = (bt-node record { key = key ; ltree = ltree ; rtree = rtree }) ; varn = varn ; varl = varl } ) next exit | tri≈ @$\neg$@a b @$\neg$@c +bt-insert node@(record { vart = (bt-node record { key = key ; ltree = ltree ; rtree = rtree }) ; varn = varn ; varl = varl } ) next exit | tri!$\approx$! !$\neg$!a b !$\neg$!c = exit node -bt-insert record {vart = (bt-node record { key = key ; ltree = ltree ; rtree = rtree }) ; varn = varn ; varl = varl } next exit | tri> @$\neg$@a @$\neg$@b c - = next (record {vart = ltree ; varn = varn ; varl = (bt-node record { key = key ; ltree = bt-empty ; rtree = rtree }) @$\text{::}$@ varl }) +bt-insert record {vart = (bt-node record { key = key ; ltree = ltree ; rtree = rtree }) ; varn = varn ; varl = varl } next exit | tri> !$\neg$!a !$\neg$!b c + = next (record {vart = ltree ; varn = varn ; varl = (bt-node record { key = key ; ltree = bt-empty ; rtree = rtree }) !$\text{::}$! varl }) -bt-insert record {vart = (bt-node record { key = key ; ltree = ltree ; rtree = rtree }) ; varn = varn ; varl = varl } next exit | tri< a @$\neg$@b @$\neg$@c - = next (record {vart = rtree ; varn = varn ; varl = (bt-node record { key = key ; ltree = ltree ; rtree = bt-empty }) @$\text{::}$@ varl }) +bt-insert record {vart = (bt-node record { key = key ; ltree = ltree ; rtree = rtree }) ; varn = varn ; varl = varl } next exit | tri< a !$\neg$!b !$\neg$!c + = next (record {vart = rtree ; varn = varn ; varl = (bt-node record { key = key ; ltree = ltree ; rtree = bt-empty }) !$\text{::}$! varl }) -- normal loop without termination -{-@$\#$@ TERMINATING @$\#$@-} -insert : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -insert env exit = bt-insert env (@$\lambda$@ env @$\rightarrow$@ insert env exit ) exit +{-!$\#$! TERMINATING !$\#$!-} +insert : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +insert env exit = bt-insert env (!$\lambda$! env !$\rightarrow$! insert env exit ) exit -init-col : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +init-col : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t init-col env exit = init-node-coler env exit exit {- -{-@$\#$@ TERMINATING @$\#$@-} -merge : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +{-!$\#$! TERMINATING !$\#$!-} +merge : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t -{-@$\#$@ TERMINATING @$\#$@-} -split-p : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -split-p env exit = split env (@$\lambda$@ env @$\rightarrow$@ merge env (@$\lambda$@ env @$\rightarrow$@ merge env exit ) ) exit +{-!$\#$! TERMINATING !$\#$!-} +split-p : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +split-p env exit = split env (!$\lambda$! env !$\rightarrow$! merge env (!$\lambda$! env !$\rightarrow$! merge env exit ) ) exit -{-@$\#$@ TERMINATING @$\#$@-} -rotate_right : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -rotate_right env exit = merge-rotate-right env (@$\lambda$@ env @$\rightarrow$@ split-p env (@$\lambda$@ env @$\rightarrow$@ merge env exit ) ) exit +{-!$\#$! TERMINATING !$\#$!-} +rotate_right : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +rotate_right env exit = merge-rotate-right env (!$\lambda$! env !$\rightarrow$! split-p env (!$\lambda$! env !$\rightarrow$! merge env exit ) ) exit -{-@$\#$@ TERMINATING @$\#$@-} -split-b : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -split-b env exit = split-branch env (@$\lambda$@ env @$\rightarrow$@ rotate_right env exit ) @$\lambda$@ env @$\rightarrow$@ merge env exit +{-!$\#$! TERMINATING !$\#$!-} +split-b : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +split-b env exit = split-branch env (!$\lambda$! env !$\rightarrow$! rotate_right env exit ) !$\lambda$! env !$\rightarrow$! merge env exit -{-@$\#$@ TERMINATING @$\#$@-} -rotate_left : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -rotate_left env exit = merge-rotate-left env (@$\lambda$@ env @$\rightarrow$@ split-b env exit ) exit +{-!$\#$! TERMINATING !$\#$!-} +rotate_left : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +rotate_left env exit = merge-rotate-left env (!$\lambda$! env !$\rightarrow$! split-b env exit ) exit -{-@$\#$@ TERMINATING @$\#$@-} -skew : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -skew env exit = skew-bt env (@$\lambda$@ env @$\rightarrow$@ rotate_left env (@$\lambda$@ env @$\rightarrow$@ split-b env exit ) ) exit +{-!$\#$! TERMINATING !$\#$!-} +skew : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +skew env exit = skew-bt env (!$\lambda$! env !$\rightarrow$! rotate_left env (!$\lambda$! env !$\rightarrow$! split-b env exit ) ) exit -merge env exit = merge-tree env (@$\lambda$@ env @$\rightarrow$@ skew env exit ) exit +merge env exit = merge-tree env (!$\lambda$! env !$\rightarrow$! skew env exit ) exit -} -- skewはnextがrotate-right。exitはsplitとなる -- skewの中にrotate-rightが内包され、実行後は必ずsplitに遷移する -- それはskewのexitと等しいので同時に記述してやる。 -skew' : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -skew' env exit = skew-bt env (@$\lambda$@ env @$\rightarrow$@ merge-rotate-left env exit exit ) exit +skew!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +skew!$\prime$! env exit = skew-bt env (!$\lambda$! env !$\rightarrow$! merge-rotate-left env exit exit ) exit -split' : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -split' env exit = split-branch env (@$\lambda$@ env @$\rightarrow$@ merge-rotate-right env (@$\lambda$@ env @$\rightarrow$@ split env exit exit ) (@$\lambda$@ env @$\rightarrow$@ split env exit exit ) ) exit +split!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +split!$\prime$! env exit = split-branch env (!$\lambda$! env !$\rightarrow$! merge-rotate-right env (!$\lambda$! env !$\rightarrow$! split env exit exit ) (!$\lambda$! env !$\rightarrow$! split env exit exit ) ) exit {- -merge' : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -merge' node@record { vart = vart ; varn = varn ; varl = [] } exit = exit node -merge' node@record { vart = vart ; varn = varn ; varl = (x @$\text{::}$@ varl@$\_{1}$@) } exit = merge' (merge-tree node (@$\lambda$@ env @$\rightarrow$@ skew' env (@$\lambda$@ env @$\rightarrow$@ split' env (@$\lambda$@ env @$\rightarrow$@ env) ) ) (@$\lambda$@ env @$\rightarrow$@ env) ) exit +merge!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +merge!$\prime$! node@record { vart = vart ; varn = varn ; varl = [] } exit = exit node +merge!$\prime$! node@record { vart = vart ; varn = varn ; varl = (x !$\text{::}$! varl!$\_{1}$!) } exit = merge!$\prime$! (merge-tree node (!$\lambda$! env !$\rightarrow$! skew!$\prime$! env (!$\lambda$! env !$\rightarrow$! split!$\prime$! env (!$\lambda$! env !$\rightarrow$! env) ) ) (!$\lambda$! env !$\rightarrow$! env) ) exit -} -whileTestP : {l : Level} {t : Set l} @$\rightarrow$@ (tree : rbt) @$\rightarrow$@ (n : @$\mathbb{N}$@) @$\rightarrow$@ (Code : Env @$\rightarrow$@ t) @$\rightarrow$@ t +whileTestP : {l : Level} {t : Set l} !$\rightarrow$! (tree : rbt) !$\rightarrow$! (n : !$\mathbb{N}$!) !$\rightarrow$! (Code : Env !$\rightarrow$! t) !$\rightarrow$! t whileTestP tree n next = next (record {vart = tree ; varn = n ; varl = [] } ) -{-@$\#$@ TERMINATING @$\#$@-} -mergeP : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -mergeP env exit = merge-tree env (@$\lambda$@ env @$\rightarrow$@ skew' env (@$\lambda$@ env @$\rightarrow$@ split' env (@$\lambda$@ env @$\rightarrow$@ mergeP env exit)) ) exit +{-!$\#$! TERMINATING !$\#$!-} +mergeP : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +mergeP env exit = merge-tree env (!$\lambda$! env !$\rightarrow$! skew!$\prime$! env (!$\lambda$! env !$\rightarrow$! split!$\prime$! env (!$\lambda$! env !$\rightarrow$! mergeP env exit)) ) exit {- -mergeP1 : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +mergeP1 : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t mergeP1 record { vart = vart ; varn = varn ; varl = [] } exit = {!!} -mergeP1 record { vart = vart ; varn = varn ; varl = (x @$\text{::}$@ varl@$\_{1}$@) } exit = {!!} +mergeP1 record { vart = vart ; varn = varn ; varl = (x !$\text{::}$! varl!$\_{1}$!) } exit = {!!} -} {- merge-tree env - (@$\lambda$@ env @$\rightarrow$@ skew-bt env - (@$\lambda$@ env @$\rightarrow$@ merge-rotate-left env - (@$\lambda$@ env @$\rightarrow$@ split-branch env - (@$\lambda$@ env @$\rightarrow$@ merge-rotate-right env - (@$\lambda$@ env @$\rightarrow$@ split env (@$\lambda$@ env @$\rightarrow$@ mergeP env exit ) (@$\lambda$@ env @$\rightarrow$@ mergeP env exit ) ) exit) - (@$\lambda$@ env @$\rightarrow$@ mergeP env exit ) ) + (!$\lambda$! env !$\rightarrow$! skew-bt env + (!$\lambda$! env !$\rightarrow$! merge-rotate-left env + (!$\lambda$! env !$\rightarrow$! split-branch env + (!$\lambda$! env !$\rightarrow$! merge-rotate-right env + (!$\lambda$! env !$\rightarrow$! split env (!$\lambda$! env !$\rightarrow$! mergeP env exit ) (!$\lambda$! env !$\rightarrow$! mergeP env exit ) ) exit) + (!$\lambda$! env !$\rightarrow$! mergeP env exit ) ) exit ) exit ) exit -} ---whileTestP : {l : Level} {t : Set l} @$\rightarrow$@ (c10 : @$\mathbb{N}$@) @$\rightarrow$@ (c11 : @$\mathbb{N}$@) @$\rightarrow$@ (Code : Envc @$\rightarrow$@ t) @$\rightarrow$@ t +--whileTestP : {l : Level} {t : Set l} !$\rightarrow$! (c10 : !$\mathbb{N}$!) !$\rightarrow$! (c11 : !$\mathbb{N}$!) !$\rightarrow$! (Code : Envc !$\rightarrow$! t) !$\rightarrow$! t --whileTestP c10 n next = next (record {varn = c10 ; vari = 0 ; c10 = c10 } ) ---whileTestPCall : (tree : rbt) @$\rightarrow$@ (n : @$\mathbb{N}$@) @$\rightarrow$@ Env ---whileTestPCall tree n = whileTestP {_} {_} tree n (@$\lambda$@ env @$\rightarrow$@ insert env (@$\lambda$@ env @$\rightarrow$@ merge env (@$\lambda$@ env @$\rightarrow$@ init-col env (@$\lambda$@ env @$\rightarrow$@ env ) ) ) ) +--whileTestPCall : (tree : rbt) !$\rightarrow$! (n : !$\mathbb{N}$!) !$\rightarrow$! Env +--whileTestPCall tree n = whileTestP {_} {_} tree n (!$\lambda$! env !$\rightarrow$! insert env (!$\lambda$! env !$\rightarrow$! merge env (!$\lambda$! env !$\rightarrow$! init-col env (!$\lambda$! env !$\rightarrow$! env ) ) ) ) -whileTestPCall' : (tree : rbt) @$\rightarrow$@ (n : @$\mathbb{N}$@) @$\rightarrow$@ Env -whileTestPCall' tree n = whileTestP {_} {_} tree n (@$\lambda$@ env @$\rightarrow$@ insert env (@$\lambda$@ env @$\rightarrow$@ mergeP env (@$\lambda$@ env @$\rightarrow$@ init-col env (@$\lambda$@ env @$\rightarrow$@ env ) ) ) ) +whileTestPCall!$\prime$! : (tree : rbt) !$\rightarrow$! (n : !$\mathbb{N}$!) !$\rightarrow$! Env +whileTestPCall!$\prime$! tree n = whileTestP {_} {_} tree n (!$\lambda$! env !$\rightarrow$! insert env (!$\lambda$! env !$\rightarrow$! mergeP env (!$\lambda$! env !$\rightarrow$! init-col env (!$\lambda$! env !$\rightarrow$! env ) ) ) ) -- 以下test部分 -test1 = whileTestPCall' bt-empty 8 -test2 = whileTestPCall' (vart test1) 10 -test3 = whileTestPCall' (vart test2) 24 -test4 = whileTestPCall' (vart test3) 31 -test5 = whileTestPCall' (vart test4) 41 -test6 = whileTestPCall' (vart test5) 45 -test7 = whileTestPCall' (vart test6) 50 -test8 = whileTestPCall' (vart test7) 59 -test9 = whileTestPCall' (vart test8) 73 -test10 = whileTestPCall' (vart test9) 74 -test11 = whileTestPCall' (vart test10) 79 +test1 = whileTestPCall!$\prime$! bt-empty 8 +test2 = whileTestPCall!$\prime$! (vart test1) 10 +test3 = whileTestPCall!$\prime$! (vart test2) 24 +test4 = whileTestPCall!$\prime$! (vart test3) 31 +test5 = whileTestPCall!$\prime$! (vart test4) 41 +test6 = whileTestPCall!$\prime$! (vart test5) 45 +test7 = whileTestPCall!$\prime$! (vart test6) 50 +test8 = whileTestPCall!$\prime$! (vart test7) 59 +test9 = whileTestPCall!$\prime$! (vart test8) 73 +test10 = whileTestPCall!$\prime$! (vart test9) 74 +test11 = whileTestPCall!$\prime$! (vart test10) 79 diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/rbt_varif.agda.replaced --- a/Paper/src/agda/rbt_varif.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/rbt_varif.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -2,7 +2,7 @@ open import Level renaming ( suc to succ ; zero to Zero ) open import Relation.Binary -open import Data.Nat hiding (_@$\leq$@_ ; _@$\leq$@?_) +open import Data.Nat hiding (_!$\leq$!_ ; _!$\leq$!?_) open import Data.List hiding ([_]) open import Data.Product open import Data.Nat.Properties as NP @@ -12,43 +12,43 @@ mutual data right-List : Set where [] : right-List - [_] : @$\mathbb{N}$@ @$\rightarrow$@ right-List - _@$\text{::}$@>_Cond_ : (x : @$\mathbb{N}$@) @$\rightarrow$@ (xs : right-List ) @$\rightarrow$@ (p : x Data.Nat.> top-r xs) @$\rightarrow$@ right-List + [_] : !$\mathbb{N}$! !$\rightarrow$! right-List + _!$\text{::}$!>_Cond_ : (x : !$\mathbb{N}$!) !$\rightarrow$! (xs : right-List ) !$\rightarrow$! (p : x Data.Nat.> top-r xs) !$\rightarrow$! right-List - top-r : right-List @$\rightarrow$@ @$\mathbb{N}$@ + top-r : right-List !$\rightarrow$! !$\mathbb{N}$! top-r [] = {!!} top-r [ x ] = x - top-r (x @$\text{::}$@> l Cond x@$\_{1}$@) = x + top-r (x !$\text{::}$!> l Cond x!$\_{1}$!) = x - insert-r : @$\mathbb{N}$@ @$\rightarrow$@ right-List @$\rightarrow$@ right-List + insert-r : !$\mathbb{N}$! !$\rightarrow$! right-List !$\rightarrow$! right-List insert-r x [] = {!!} insert-r x [ y ] with <-cmp x y - ... | tri< a @$\neg$@b @$\neg$@c = [ y ] - ... | tri≈ @$\neg$@a b @$\neg$@c = [ y ] - ... | tri> @$\neg$@a @$\neg$@b c = x @$\text{::}$@> [ y ] Cond c - insert-r x (y @$\text{::}$@> ys Cond p) with <-cmp x y - ... | tri< a @$\neg$@b @$\neg$@c = (y @$\text{::}$@> ys Cond p) - ... | tri≈ @$\neg$@a b @$\neg$@c = (y @$\text{::}$@> ys Cond p) - ... | tri> @$\neg$@a @$\neg$@b c = x @$\text{::}$@> (y @$\text{::}$@> ys Cond p) Cond c + ... | tri< a !$\neg$!b !$\neg$!c = [ y ] + ... | tri!$\approx$! !$\neg$!a b !$\neg$!c = [ y ] + ... | tri> !$\neg$!a !$\neg$!b c = x !$\text{::}$!> [ y ] Cond c + insert-r x (y !$\text{::}$!> ys Cond p) with <-cmp x y + ... | tri< a !$\neg$!b !$\neg$!c = (y !$\text{::}$!> ys Cond p) + ... | tri!$\approx$! !$\neg$!a b !$\neg$!c = (y !$\text{::}$!> ys Cond p) + ... | tri> !$\neg$!a !$\neg$!b c = x !$\text{::}$!> (y !$\text{::}$!> ys Cond p) Cond c data left-List : Set where [] : left-List - [_] : @$\mathbb{N}$@ @$\rightarrow$@ left-List - _<@$\text{::}$@_Cond_ : (x : @$\mathbb{N}$@) @$\rightarrow$@ (xs : left-List ) @$\rightarrow$@ (p : x Data.Nat.< top-l xs) @$\rightarrow$@ left-List + [_] : !$\mathbb{N}$! !$\rightarrow$! left-List + _ @$\neg$@a @$\neg$@b c = l - insert-l x l@(y <@$\text{::}$@ ys Cond p) with <-cmp x y - ... | tri< a @$\neg$@b @$\neg$@c = x <@$\text{::}$@ l Cond a - ... | tri≈ @$\neg$@a b @$\neg$@c = l + ... | tri< a !$\neg$!b !$\neg$!c = x !$\neg$!a !$\neg$!b c = l + insert-l x l@(y @$\neg$@a @$\neg$@b c = l + ... | tri> !$\neg$!a !$\neg$!b c = l diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/syllogism.agda.replaced --- a/Paper/src/agda/syllogism.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/syllogism.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,2 +1,2 @@ -syllogism : {A B C : Set} @$\rightarrow$@ ((A @$\rightarrow$@ B) @$\wedge$@ (B @$\rightarrow$@ C)) @$\rightarrow$@ (A @$\rightarrow$@ C) -syllogism x a = _@$\wedge$@_.p2 x (_@$\wedge$@_.p1 x a) +syllogism : {A B C : Set} !$\rightarrow$! ((A !$\rightarrow$! B) !$\wedge$! (B !$\rightarrow$! C)) !$\rightarrow$! (A !$\rightarrow$! C) +syllogism x a = _!$\wedge$!_.p2 x (_!$\wedge$!_.p1 x a) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/agda/utilities.agda.replaced --- a/Paper/src/agda/utilities.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/agda/utilities.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,171 +1,171 @@ -{-@$\#$@ OPTIONS --allow-unsolved-metas @$\#$@-} +{-!$\#$! OPTIONS --allow-unsolved-metas !$\#$!-} module utilities where open import Function open import Data.Nat open import Data.Product -open import Data.Bool hiding ( _≟_ ; _@$\leq$@?_) +open import Data.Bool hiding ( _≟_ ; _!$\leq$!?_) open import Level renaming ( suc to succ ; zero to Zero ) -open import Relation.Nullary using (@$\neg$@_; Dec; yes; no) +open import Relation.Nullary using (!$\neg$!_; Dec; yes; no) open import Relation.Binary.PropositionalEquality -Pred : Set @$\rightarrow$@ Set@$\_{1}$@ -Pred X = X @$\rightarrow$@ Set +Pred : Set !$\rightarrow$! Set!$\_{1}$! +Pred X = X !$\rightarrow$! Set -Imply : Set @$\rightarrow$@ Set @$\rightarrow$@ Set -Imply X Y = X @$\rightarrow$@ Y +Imply : Set !$\rightarrow$! Set !$\rightarrow$! Set +Imply X Y = X !$\rightarrow$! Y -Iff : Set @$\rightarrow$@ Set @$\rightarrow$@ Set -Iff X Y = Imply X Y @$\times$@ Imply Y X +Iff : Set !$\rightarrow$! Set !$\rightarrow$! Set +Iff X Y = Imply X Y !$\times$! Imply Y X -record _@$\wedge$@_ {n : Level } (a : Set n) (b : Set n): Set n where +record _!$\wedge$!_ {n : Level } (a : Set n) (b : Set n): Set n where field pi1 : a pi2 : b -open _@$\wedge$@_ +open _!$\wedge$!_ -_-_ : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ +_-_ : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! x - zero = x zero - _ = zero (suc x) - (suc y) = x - y -+zero : { y : @$\mathbb{N}$@ } @$\rightarrow$@ y + zero @$\equiv$@ y ++zero : { y : !$\mathbb{N}$! } !$\rightarrow$! y + zero !$\equiv$! y +zero {zero} = refl -+zero {suc y} = cong ( @$\lambda$@ x @$\rightarrow$@ suc x ) ( +zero {y} ) ++zero {suc y} = cong ( !$\lambda$! x !$\rightarrow$! suc x ) ( +zero {y} ) -+-sym : { x y : @$\mathbb{N}$@ } @$\rightarrow$@ x + y @$\equiv$@ y + x ++-sym : { x y : !$\mathbb{N}$! } !$\rightarrow$! x + y !$\equiv$! y + x +-sym {zero} {zero} = refl -+-sym {zero} {suc y} = let open @$\equiv$@-Reasoning in ++-sym {zero} {suc y} = let open !$\equiv$!-Reasoning in begin zero + suc y - @$\equiv$@@$\langle$@@$\rangle$@ + !$\equiv$!!$\langle$!!$\rangle$! suc y - @$\equiv$@@$\langle$@ sym +zero @$\rangle$@ + !$\equiv$!!$\langle$! sym +zero !$\rangle$! suc y + zero - @$\blacksquare$@ -+-sym {suc x} {zero} = let open @$\equiv$@-Reasoning in + !$\blacksquare$! ++-sym {suc x} {zero} = let open !$\equiv$!-Reasoning in begin suc x + zero - @$\equiv$@@$\langle$@ +zero @$\rangle$@ + !$\equiv$!!$\langle$! +zero !$\rangle$! suc x - @$\equiv$@@$\langle$@@$\rangle$@ + !$\equiv$!!$\langle$!!$\rangle$! zero + suc x - @$\blacksquare$@ -+-sym {suc x} {suc y} = cong ( @$\lambda$@ z @$\rightarrow$@ suc z ) ( let open @$\equiv$@-Reasoning in + !$\blacksquare$! ++-sym {suc x} {suc y} = cong ( !$\lambda$! z !$\rightarrow$! suc z ) ( let open !$\equiv$!-Reasoning in begin x + suc y - @$\equiv$@@$\langle$@ +-sym {x} {suc y} @$\rangle$@ + !$\equiv$!!$\langle$! +-sym {x} {suc y} !$\rangle$! suc (y + x) - @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ suc z ) (+-sym {y} {x}) @$\rangle$@ + !$\equiv$!!$\langle$! cong ( !$\lambda$! z !$\rightarrow$! suc z ) (+-sym {y} {x}) !$\rangle$! suc (x + y) - @$\equiv$@@$\langle$@ sym ( +-sym {y} {suc x}) @$\rangle$@ + !$\equiv$!!$\langle$! sym ( +-sym {y} {suc x}) !$\rangle$! y + suc x - @$\blacksquare$@ ) + !$\blacksquare$! ) -minus-plus : { x y : @$\mathbb{N}$@ } @$\rightarrow$@ (suc x - 1) + (y + 1) @$\equiv$@ suc x + y +minus-plus : { x y : !$\mathbb{N}$! } !$\rightarrow$! (suc x - 1) + (y + 1) !$\equiv$! suc x + y minus-plus {zero} {y} = +-sym {y} {1} -minus-plus {suc x} {y} = cong ( @$\lambda$@ z @$\rightarrow$@ suc z ) (minus-plus {x} {y}) +minus-plus {suc x} {y} = cong ( !$\lambda$! z !$\rightarrow$! suc z ) (minus-plus {x} {y}) -+1@$\equiv$@suc : { x : @$\mathbb{N}$@ } @$\rightarrow$@ x + 1 @$\equiv$@ suc x -+1@$\equiv$@suc {zero} = refl -+1@$\equiv$@suc {suc x} = cong ( @$\lambda$@ z @$\rightarrow$@ suc z ) ( +1@$\equiv$@suc {x} ) ++1!$\equiv$!suc : { x : !$\mathbb{N}$! } !$\rightarrow$! x + 1 !$\equiv$! suc x ++1!$\equiv$!suc {zero} = refl ++1!$\equiv$!suc {suc x} = cong ( !$\lambda$! z !$\rightarrow$! suc z ) ( +1!$\equiv$!suc {x} ) -lt : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Bool -lt x y with (suc x ) @$\leq$@? y +lt : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! Bool +lt x y with (suc x ) !$\leq$!? y lt x y | yes p = true -lt x y | no @$\neg$@p = false +lt x y | no !$\neg$!p = false -pred@$\mathbb{N}$@ : {n : @$\mathbb{N}$@ } @$\rightarrow$@ lt 0 n @$\equiv$@ true @$\rightarrow$@ @$\mathbb{N}$@ -pred@$\mathbb{N}$@ {zero} () -pred@$\mathbb{N}$@ {suc n} refl = n +pred!$\mathbb{N}$! : {n : !$\mathbb{N}$! } !$\rightarrow$! lt 0 n !$\equiv$! true !$\rightarrow$! !$\mathbb{N}$! +pred!$\mathbb{N}$! {zero} () +pred!$\mathbb{N}$! {suc n} refl = n -pred@$\mathbb{N}$@+1=n : {n : @$\mathbb{N}$@ } @$\rightarrow$@ (less : lt 0 n @$\equiv$@ true ) @$\rightarrow$@ (pred@$\mathbb{N}$@ less) + 1 @$\equiv$@ n -pred@$\mathbb{N}$@+1=n {zero} () -pred@$\mathbb{N}$@+1=n {suc n} refl = +1@$\equiv$@suc +pred!$\mathbb{N}$!+1=n : {n : !$\mathbb{N}$! } !$\rightarrow$! (less : lt 0 n !$\equiv$! true ) !$\rightarrow$! (pred!$\mathbb{N}$! less) + 1 !$\equiv$! n +pred!$\mathbb{N}$!+1=n {zero} () +pred!$\mathbb{N}$!+1=n {suc n} refl = +1!$\equiv$!suc -suc-pred@$\mathbb{N}$@=n : {n : @$\mathbb{N}$@ } @$\rightarrow$@ (less : lt 0 n @$\equiv$@ true ) @$\rightarrow$@ suc (pred@$\mathbb{N}$@ less) @$\equiv$@ n -suc-pred@$\mathbb{N}$@=n {zero} () -suc-pred@$\mathbb{N}$@=n {suc n} refl = refl +suc-pred!$\mathbb{N}$!=n : {n : !$\mathbb{N}$! } !$\rightarrow$! (less : lt 0 n !$\equiv$! true ) !$\rightarrow$! suc (pred!$\mathbb{N}$! less) !$\equiv$! n +suc-pred!$\mathbb{N}$!=n {zero} () +suc-pred!$\mathbb{N}$!=n {suc n} refl = refl -Equal : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Bool +Equal : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! Bool Equal x y with x ≟ y Equal x y | yes p = true -Equal x y | no @$\neg$@p = false +Equal x y | no !$\neg$!p = false -_@$\Rightarrow$@_ : Bool @$\rightarrow$@ Bool @$\rightarrow$@ Bool -false @$\Rightarrow$@ _ = true -true @$\Rightarrow$@ true = true -true @$\Rightarrow$@ false = false +_!$\Rightarrow$!_ : Bool !$\rightarrow$! Bool !$\rightarrow$! Bool +false !$\Rightarrow$! _ = true +true !$\Rightarrow$! true = true +true !$\Rightarrow$! false = false -@$\Rightarrow$@t : {x : Bool} @$\rightarrow$@ x @$\Rightarrow$@ true @$\equiv$@ true -@$\Rightarrow$@t {x} with x -@$\Rightarrow$@t {x} | false = refl -@$\Rightarrow$@t {x} | true = refl +!$\Rightarrow$!t : {x : Bool} !$\rightarrow$! x !$\Rightarrow$! true !$\equiv$! true +!$\Rightarrow$!t {x} with x +!$\Rightarrow$!t {x} | false = refl +!$\Rightarrow$!t {x} | true = refl -f@$\Rightarrow$@ : {x : Bool} @$\rightarrow$@ false @$\Rightarrow$@ x @$\equiv$@ true -f@$\Rightarrow$@ {x} with x -f@$\Rightarrow$@ {x} | false = refl -f@$\Rightarrow$@ {x} | true = refl +f!$\Rightarrow$! : {x : Bool} !$\rightarrow$! false !$\Rightarrow$! x !$\equiv$! true +f!$\Rightarrow$! {x} with x +f!$\Rightarrow$! {x} | false = refl +f!$\Rightarrow$! {x} | true = refl -@$\wedge$@-pi1 : { x y : Bool } @$\rightarrow$@ x @$\wedge$@ y @$\equiv$@ true @$\rightarrow$@ x @$\equiv$@ true -@$\wedge$@-pi1 {x} {y} eq with x | y | eq -@$\wedge$@-pi1 {x} {y} eq | false | b | () -@$\wedge$@-pi1 {x} {y} eq | true | false | () -@$\wedge$@-pi1 {x} {y} eq | true | true | refl = refl +!$\wedge$!-pi1 : { x y : Bool } !$\rightarrow$! x !$\wedge$! y !$\equiv$! true !$\rightarrow$! x !$\equiv$! true +!$\wedge$!-pi1 {x} {y} eq with x | y | eq +!$\wedge$!-pi1 {x} {y} eq | false | b | () +!$\wedge$!-pi1 {x} {y} eq | true | false | () +!$\wedge$!-pi1 {x} {y} eq | true | true | refl = refl -@$\wedge$@-pi2 : { x y : Bool } @$\rightarrow$@ x @$\wedge$@ y @$\equiv$@ true @$\rightarrow$@ y @$\equiv$@ true -@$\wedge$@-pi2 {x} {y} eq with x | y | eq -@$\wedge$@-pi2 {x} {y} eq | false | b | () -@$\wedge$@-pi2 {x} {y} eq | true | false | () -@$\wedge$@-pi2 {x} {y} eq | true | true | refl = refl +!$\wedge$!-pi2 : { x y : Bool } !$\rightarrow$! x !$\wedge$! y !$\equiv$! true !$\rightarrow$! y !$\equiv$! true +!$\wedge$!-pi2 {x} {y} eq with x | y | eq +!$\wedge$!-pi2 {x} {y} eq | false | b | () +!$\wedge$!-pi2 {x} {y} eq | true | false | () +!$\wedge$!-pi2 {x} {y} eq | true | true | refl = refl -@$\wedge$@true : { x : Bool } @$\rightarrow$@ x @$\wedge$@ true @$\equiv$@ x -@$\wedge$@true {x} with x -@$\wedge$@true {x} | false = refl -@$\wedge$@true {x} | true = refl +!$\wedge$!true : { x : Bool } !$\rightarrow$! x !$\wedge$! true !$\equiv$! x +!$\wedge$!true {x} with x +!$\wedge$!true {x} | false = refl +!$\wedge$!true {x} | true = refl -true@$\wedge$@ : { x : Bool } @$\rightarrow$@ true @$\wedge$@ x @$\equiv$@ x -true@$\wedge$@ {x} with x -true@$\wedge$@ {x} | false = refl -true@$\wedge$@ {x} | true = refl -bool-case : ( x : Bool ) { p : Set } @$\rightarrow$@ ( x @$\equiv$@ true @$\rightarrow$@ p ) @$\rightarrow$@ ( x @$\equiv$@ false @$\rightarrow$@ p ) @$\rightarrow$@ p +true!$\wedge$! : { x : Bool } !$\rightarrow$! true !$\wedge$! x !$\equiv$! x +true!$\wedge$! {x} with x +true!$\wedge$! {x} | false = refl +true!$\wedge$! {x} | true = refl +bool-case : ( x : Bool ) { p : Set } !$\rightarrow$! ( x !$\equiv$! true !$\rightarrow$! p ) !$\rightarrow$! ( x !$\equiv$! false !$\rightarrow$! p ) !$\rightarrow$! p bool-case x T F with x bool-case x T F | false = F refl bool-case x T F | true = T refl -impl@$\Rightarrow$@ : {x y : Bool} @$\rightarrow$@ (x @$\equiv$@ true @$\rightarrow$@ y @$\equiv$@ true ) @$\rightarrow$@ x @$\Rightarrow$@ y @$\equiv$@ true -impl@$\Rightarrow$@ {x} {y} p = bool-case x (@$\lambda$@ x=t @$\rightarrow$@ let open @$\equiv$@-Reasoning in +impl!$\Rightarrow$! : {x y : Bool} !$\rightarrow$! (x !$\equiv$! true !$\rightarrow$! y !$\equiv$! true ) !$\rightarrow$! x !$\Rightarrow$! y !$\equiv$! true +impl!$\Rightarrow$! {x} {y} p = bool-case x (!$\lambda$! x=t !$\rightarrow$! let open !$\equiv$!-Reasoning in begin - x @$\Rightarrow$@ y - @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ x @$\Rightarrow$@ z ) (p x=t ) @$\rangle$@ - x @$\Rightarrow$@ true - @$\equiv$@@$\langle$@ @$\Rightarrow$@t @$\rangle$@ + x !$\Rightarrow$! y + !$\equiv$!!$\langle$! cong ( !$\lambda$! z !$\rightarrow$! x !$\Rightarrow$! z ) (p x=t ) !$\rangle$! + x !$\Rightarrow$! true + !$\equiv$!!$\langle$! !$\Rightarrow$!t !$\rangle$! true - @$\blacksquare$@ - ) ( @$\lambda$@ x=f @$\rightarrow$@ let open @$\equiv$@-Reasoning in + !$\blacksquare$! + ) ( !$\lambda$! x=f !$\rightarrow$! let open !$\equiv$!-Reasoning in begin - x @$\Rightarrow$@ y - @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ z @$\Rightarrow$@ y ) x=f @$\rangle$@ + x !$\Rightarrow$! y + !$\equiv$!!$\langle$! cong ( !$\lambda$! z !$\rightarrow$! z !$\Rightarrow$! y ) x=f !$\rangle$! true - @$\blacksquare$@ + !$\blacksquare$! ) -Equal@$\rightarrow$@@$\equiv$@ : { x y : @$\mathbb{N}$@ } @$\rightarrow$@ Equal x y @$\equiv$@ true @$\rightarrow$@ x @$\equiv$@ y -Equal@$\rightarrow$@@$\equiv$@ {x} {y} eq with x ≟ y -Equal@$\rightarrow$@@$\equiv$@ {x} {y} refl | yes refl = refl -Equal@$\rightarrow$@@$\equiv$@ {x} {y} () | no @$\neg$@p +Equal!$\rightarrow$!!$\equiv$! : { x y : !$\mathbb{N}$! } !$\rightarrow$! Equal x y !$\equiv$! true !$\rightarrow$! x !$\equiv$! y +Equal!$\rightarrow$!!$\equiv$! {x} {y} eq with x ≟ y +Equal!$\rightarrow$!!$\equiv$! {x} {y} refl | yes refl = refl +Equal!$\rightarrow$!!$\equiv$! {x} {y} () | no !$\neg$!p -Equal+1 : { x y : @$\mathbb{N}$@ } @$\rightarrow$@ Equal x y @$\equiv$@ Equal (suc x) (suc y) +Equal+1 : { x y : !$\mathbb{N}$! } !$\rightarrow$! Equal x y !$\equiv$! Equal (suc x) (suc y) Equal+1 {x} {y} with x ≟ y Equal+1 {x} {.x} | yes refl = {!!} -Equal+1 {x} {y} | no @$\neg$@p = {!!} +Equal+1 {x} {y} | no !$\neg$!p = {!!} open import Data.Empty -@$\equiv$@@$\rightarrow$@Equal : { x y : @$\mathbb{N}$@ } @$\rightarrow$@ x @$\equiv$@ y @$\rightarrow$@ Equal x y @$\equiv$@ true -@$\equiv$@@$\rightarrow$@Equal {x} {.x} refl with x ≟ x -@$\equiv$@@$\rightarrow$@Equal {x} {.x} refl | yes refl = refl -@$\equiv$@@$\rightarrow$@Equal {x} {.x} refl | no @$\neg$@p = @$\bot$@-elim ( @$\neg$@p refl ) +!$\equiv$!!$\rightarrow$!Equal : { x y : !$\mathbb{N}$! } !$\rightarrow$! x !$\equiv$! y !$\rightarrow$! Equal x y !$\equiv$! true +!$\equiv$!!$\rightarrow$!Equal {x} {.x} refl with x ≟ x +!$\equiv$!!$\rightarrow$!Equal {x} {.x} refl | yes refl = refl +!$\equiv$!!$\rightarrow$!Equal {x} {.x} refl | no !$\neg$!p = !$\bot$!-elim ( !$\neg$!p refl ) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/atton-master-meta-sample.agda.replaced --- a/Paper/src/atton-master-meta-sample.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/atton-master-meta-sample.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -3,7 +3,7 @@ open import Data.Nat open import Data.Unit open import Function -Int = @$\mathbb{N}$@ +Int = !$\mathbb{N}$! record Context : Set where field @@ -16,33 +16,33 @@ record Meta : Set where field context : Context - c' : Int + c!$\prime$! : Int next : N.CodeSegment Context Context open import subtype Meta as M instance _ : N.DataSegment Context - _ = record { get = id ; set = (\_ c @$\rightarrow$@ c) } + _ = record { get = id ; set = (\_ c !$\rightarrow$! c) } _ : M.DataSegment Context - _ = record { get = (\m @$\rightarrow$@ Meta.context m) ; - set = (\m c @$\rightarrow$@ record m {context = c}) } + _ = record { get = (\m !$\rightarrow$! Meta.context m) ; + set = (\m c !$\rightarrow$! record m {context = c}) } _ : M.DataSegment Meta - _ = record { get = id ; set = (\_ m @$\rightarrow$@ m) } + _ = record { get = id ; set = (\_ m !$\rightarrow$! m) } -liftContext : {X Y : Set} {{_ : N.DataSegment X}} {{_ : N.DataSegment Y}} @$\rightarrow$@ N.CodeSegment X Y @$\rightarrow$@ N.CodeSegment Context Context -liftContext {{x}} {{y}} (N.cs f) = N.cs (\c @$\rightarrow$@ N.DataSegment.set y c (f (N.DataSegment.get x c))) +liftContext : {X Y : Set} {{_ : N.DataSegment X}} {{_ : N.DataSegment Y}} !$\rightarrow$! N.CodeSegment X Y !$\rightarrow$! N.CodeSegment Context Context +liftContext {{x}} {{y}} (N.cs f) = N.cs (\c !$\rightarrow$! N.DataSegment.set y c (f (N.DataSegment.get x c))) -liftMeta : {X Y : Set} {{_ : M.DataSegment X}} {{_ : M.DataSegment Y}} @$\rightarrow$@ N.CodeSegment X Y @$\rightarrow$@ M.CodeSegment X Y +liftMeta : {X Y : Set} {{_ : M.DataSegment X}} {{_ : M.DataSegment Y}} !$\rightarrow$! N.CodeSegment X Y !$\rightarrow$! M.CodeSegment X Y liftMeta (N.cs f) = M.cs f -gotoMeta : {I O : Set} {{_ : N.DataSegment I}} {{_ : N.DataSegment O}} @$\rightarrow$@ M.CodeSegment Meta Meta @$\rightarrow$@ N.CodeSegment I O @$\rightarrow$@ Meta @$\rightarrow$@ Meta +gotoMeta : {I O : Set} {{_ : N.DataSegment I}} {{_ : N.DataSegment O}} !$\rightarrow$! M.CodeSegment Meta Meta !$\rightarrow$! N.CodeSegment I O !$\rightarrow$! Meta !$\rightarrow$! Meta gotoMeta mCode code m = M.exec mCode (record m {next = (liftContext code)}) push : M.CodeSegment Meta Meta -push = M.cs (\m @$\rightarrow$@ M.exec (liftMeta (Meta.next m)) (record m {c' = Context.c (Meta.context m)})) +push = M.cs (\m !$\rightarrow$! M.exec (liftMeta (Meta.next m)) (record m {c!$\prime$! = Context.c (Meta.context m)})) record ds0 : Set where @@ -56,22 +56,22 @@ instance _ : N.DataSegment ds0 - _ = record { set = (\c d @$\rightarrow$@ record c {a = (ds0.a d) ; b = (ds0.b d)}) - ; get = (\c @$\rightarrow$@ record { a = (Context.a c) ; b = (Context.b c)})} + _ = record { set = (\c d !$\rightarrow$! record c {a = (ds0.a d) ; b = (ds0.b d)}) + ; get = (\c !$\rightarrow$! record { a = (Context.a c) ; b = (Context.b c)})} _ : N.DataSegment ds1 - _ = record { set = (\c d @$\rightarrow$@ record c {c = (ds1.c d)}) - ; get = (\c @$\rightarrow$@ record { c = (Context.c c)})} + _ = record { set = (\c d !$\rightarrow$! record c {c = (ds1.c d)}) + ; get = (\c !$\rightarrow$! record { c = (Context.c c)})} cs2 : N.CodeSegment ds1 ds1 cs2 = N.cs id cs1 : N.CodeSegment ds1 ds1 -cs1 = N.cs (\d @$\rightarrow$@ N.goto cs2 d) +cs1 = N.cs (\d !$\rightarrow$! N.goto cs2 d) cs0 : N.CodeSegment ds0 ds1 -cs0 = N.cs (\d @$\rightarrow$@ N.goto cs1 (record {c = (ds0.a d) + (ds0.b d)})) +cs0 = N.cs (\d !$\rightarrow$! N.goto cs1 (record {c = (ds0.a d) + (ds0.b d)})) main : Meta -main = gotoMeta push cs0 (record {context = (record {a = 100 ; b = 50 ; c = 70}) ; c' = 0 ; next = (N.cs id)}) --- record {context = record {a = 100 ; b = 50 ; c = 150} ; c' = 70 ; next = (N.cs id)} +main = gotoMeta push cs0 (record {context = (record {a = 100 ; b = 50 ; c = 70}) ; c!$\prime$! = 0 ; next = (N.cs id)}) +-- record {context = record {a = 100 ; b = 50 ; c = 150} ; c!$\prime$! = 70 ; next = (N.cs id)} diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/atton-master-sample.agda.replaced --- a/Paper/src/atton-master-sample.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/atton-master-sample.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -3,7 +3,7 @@ open import Data.Nat open import Data.Unit open import Function -Int = @$\mathbb{N}$@ +Int = !$\mathbb{N}$! record Context : Set where field @@ -27,20 +27,20 @@ instance _ : DataSegment ds0 - _ = record { set = (\c d @$\rightarrow$@ record c {a = (ds0.a d) ; b = (ds0.b d)}) - ; get = (\c @$\rightarrow$@ record { a = (Context.a c) ; b = (Context.b c)})} + _ = record { set = (\c d !$\rightarrow$! record c {a = (ds0.a d) ; b = (ds0.b d)}) + ; get = (\c !$\rightarrow$! record { a = (Context.a c) ; b = (Context.b c)})} _ : DataSegment ds1 - _ = record { set = (\c d @$\rightarrow$@ record c {c = (ds1.c d)}) - ; get = (\c @$\rightarrow$@ record { c = (Context.c c)})} + _ = record { set = (\c d !$\rightarrow$! record c {c = (ds1.c d)}) + ; get = (\c !$\rightarrow$! record { c = (Context.c c)})} cs2 : CodeSegment ds1 ds1 cs2 = cs id cs1 : CodeSegment ds1 ds1 -cs1 = cs (\d @$\rightarrow$@ goto cs2 d) +cs1 = cs (\d !$\rightarrow$! goto cs2 d) cs0 : CodeSegment ds0 ds1 -cs0 = cs (\d @$\rightarrow$@ goto cs1 (record {c = (ds0.a d) + (ds0.b d)})) +cs0 = cs (\d !$\rightarrow$! goto cs1 (record {c = (ds0.a d) + (ds0.b d)})) main : ds1 main = goto cs0 (record {a = 100 ; b = 50}) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/axiom-taut.agda.replaced --- a/Paper/src/axiom-taut.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/axiom-taut.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,10 +1,10 @@ -_@$\Rightarrow$@_ : Bool @$\rightarrow$@ Bool @$\rightarrow$@ Bool -false @$\Rightarrow$@ _ = true -true @$\Rightarrow$@ true = true -true @$\Rightarrow$@ false = false +_!$\Rightarrow$!_ : Bool !$\rightarrow$! Bool !$\rightarrow$! Bool +false !$\Rightarrow$! _ = true +true !$\Rightarrow$! true = true +true !$\Rightarrow$! false = false -Axiom : Cond @$\rightarrow$@ PrimComm @$\rightarrow$@ Cond @$\rightarrow$@ Set -Axiom pre comm post = @$\forall$@ (env : Env) @$\rightarrow$@ (pre env) @$\Rightarrow$@ ( post (comm env)) @$\equiv$@ true +Axiom : Cond !$\rightarrow$! PrimComm !$\rightarrow$! Cond !$\rightarrow$! Set +Axiom pre comm post = !$\forall$! (env : Env) !$\rightarrow$! (pre env) !$\Rightarrow$! ( post (comm env)) !$\equiv$! true -Tautology : Cond @$\rightarrow$@ Cond @$\rightarrow$@ Set -Tautology pre post = @$\forall$@ (env : Env) @$\rightarrow$@ (pre env) @$\Rightarrow$@ (post env) @$\equiv$@ true +Tautology : Cond !$\rightarrow$! Cond !$\rightarrow$! Set +Tautology pre post = !$\forall$! (env : Env) !$\rightarrow$! (pre env) !$\Rightarrow$! (post env) !$\equiv$! true diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/bt_impl/bt_env.agda --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/bt_impl/bt_env.agda Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,12 @@ +data bt {n : Level} (A : Set n) : Set n where + leaf : bt A + node : (key : ℕ) → (value : A) → + (left : bt A ) → (right : bt A ) → bt A + +record Env {n : Level} (A : Set n) : Set n where + field + varn : ℕ + varv : A + vart : bt A + varl : List (bt A) +open Env \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/bt_impl/bt_env.agda.replaced --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/bt_impl/bt_env.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,12 @@ +data bt {n : Level} (A : Set n) : Set n where + leaf : bt A + node : (key : !$\mathbb{N}$!) !$\rightarrow$! (value : A) !$\rightarrow$! + (left : bt A ) !$\rightarrow$! (right : bt A ) !$\rightarrow$! bt A + +record Env {n : Level} (A : Set n) : Set n where + field + varn : !$\mathbb{N}$! + varv : A + vart : bt A + varl : List (bt A) +open Env \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/bt_impl/find.agda --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/bt_impl/find.agda Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,12 @@ +find : {n m : Level} {A : Set n} {t : Set m} → (env : Env A ) + → (next : (env : Env A ) → t ) + → (exit : (env : Env A ) → t ) → t +find env next exit = find-c (vart env) env next exit where + find-c : {n m : Level} {A : Set n} {t : Set m} → (tree : bt A) → (env : Env A ) + → (next : (env : Env A ) → t ) + → (exit : (env : Env A ) → t ) → t + find-c leaf env next exit = exit env + find-c n@(node key-t value ltree rtree) env next exit with <-cmp (varn env) key-t + ... | tri< a ¬b ¬c = find-c ltree record env {vart = ltree ; varl = (n ∷ (varl env))} next exit + ... | tri≈ ¬a b ¬c = exit record env {vart = n} + ... | tri> ¬a ¬b c = find-c rtree record env {vart = rtree ; varl = (n ∷ (varl env))} next exit \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/bt_impl/find.agda.replaced --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/bt_impl/find.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,12 @@ +find : {n m : Level} {A : Set n} {t : Set m} !$\rightarrow$! (env : Env A ) + !$\rightarrow$! (next : (env : Env A ) !$\rightarrow$! t ) + !$\rightarrow$! (exit : (env : Env A ) !$\rightarrow$! t ) !$\rightarrow$! t +find env next exit = find-c (vart env) env next exit where + find-c : {n m : Level} {A : Set n} {t : Set m} !$\rightarrow$! (tree : bt A) !$\rightarrow$! (env : Env A ) + !$\rightarrow$! (next : (env : Env A ) !$\rightarrow$! t ) + !$\rightarrow$! (exit : (env : Env A ) !$\rightarrow$! t ) !$\rightarrow$! t + find-c leaf env next exit = exit env + find-c n@(node key-t value ltree rtree) env next exit with <-cmp (varn env) key-t + ... | tri< a !$\neg$!b !$\neg$!c = find-c ltree record env {vart = ltree ; varl = (n !$\text{::}$! (varl env))} next exit + ... | tri!$\approx$! !$\neg$!a b !$\neg$!c = exit record env {vart = n} + ... | tri> !$\neg$!a !$\neg$!b c = find-c rtree record env {vart = rtree ; varl = (n !$\text{::}$! (varl env))} next exit \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/bt_impl/replace.agda --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/bt_impl/replace.agda Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,14 @@ +replace : {n m : Level} {A : Set n} {t : Set m} → (env : Env A ) + → (next : Env A → t ) + → (exit : Env A → t) → t +replace env next exit = replace-c (varl env) env next exit where + replace-c : {n m : Level} {A : Set n} {t : Set m} → List (bt A) → (env : Env A ) + → (next : Env A → t ) + → (exit : Env A → t) → t + replace-c st env next exit with st + ... | [] = exit env + ... | leaf ∷ st1 = replace-c st1 env next exit + ... | n@(node key-t value ltree rtree) ∷ st1 with <-cmp (varn env) (key-t) + ... | tri< a ¬b ¬c = replace-c st1 record env{vart = (node key-t value (vart env) rtree); varl = st1} next exit + ... | tri≈ ¬a b ¬c = replace-c st1 record env{vart = (node key-t (varv env) ltree rtree); varl = st1} next exit + ... | tri> ¬a ¬b c = replace-c st1 record env{vart = (node key-t value ltree (vart env)); varl = st1} next exit \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/bt_impl/replace.agda.replaced --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/bt_impl/replace.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,14 @@ +replace : {n m : Level} {A : Set n} {t : Set m} !$\rightarrow$! (env : Env A ) + !$\rightarrow$! (next : Env A !$\rightarrow$! t ) + !$\rightarrow$! (exit : Env A !$\rightarrow$! t) !$\rightarrow$! t +replace env next exit = replace-c (varl env) env next exit where + replace-c : {n m : Level} {A : Set n} {t : Set m} !$\rightarrow$! List (bt A) !$\rightarrow$! (env : Env A ) + !$\rightarrow$! (next : Env A !$\rightarrow$! t ) + !$\rightarrow$! (exit : Env A !$\rightarrow$! t) !$\rightarrow$! t + replace-c st env next exit with st + ... | [] = exit env + ... | leaf !$\text{::}$! st1 = replace-c st1 env next exit + ... | n@(node key-t value ltree rtree) !$\text{::}$! st1 with <-cmp (varn env) (key-t) + ... | tri< a !$\neg$!b !$\neg$!c = replace-c st1 record env{vart = (node key-t value (vart env) rtree); varl = st1} next exit + ... | tri!$\approx$! !$\neg$!a b !$\neg$!c = replace-c st1 record env{vart = (node key-t (varv env) ltree rtree); varl = st1} next exit + ... | tri> !$\neg$!a !$\neg$!b c = replace-c st1 record env{vart = (node key-t value ltree (vart env)); varl = st1} next exit \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/bt_verif/find.agda --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/bt_verif/find.agda Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,12 @@ +findP : {n m : Level} {A : Set n} {t : Set m} → (env : Env A) + → treeInvariant env ∧ stackInvariant env + → (exit : (env : Env A) → treeInvariant env ∧ stackInvariant env → t ) → t +findP env Cond exit = findP-c (vart env) env Cond exit where + findP-c : {n m : Level} {A : Set n} {t : Set m} → (tree : bt A) → (env : Env A) + → treeInvariant env ∧ stackInvariant env + → (exit : (env : Env A) → treeInvariant env ∧ stackInvariant env → t ) → t + findP-c leaf env Cond exit = exit env Cond + findP-c n@(node key-t value ltree rtree) env Cond exit with <-cmp key-t (varn env) + ... | tri< a ¬b ¬c = findP-c ltree record env {vart = ltree ; varl = (n ∷ (varl env))} {!!} exit + ... | tri≈ ¬a b ¬c = exit record env {vart = n} {!!} + ... | tri> ¬a ¬b c = findP-c rtree record env {vart = rtree ; varl = (n ∷ (varl env))} {!!} exit \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/bt_verif/find.agda.replaced --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/bt_verif/find.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,12 @@ +findP : {n m : Level} {A : Set n} {t : Set m} !$\rightarrow$! (env : Env A) + !$\rightarrow$! treeInvariant env !$\wedge$! stackInvariant env + !$\rightarrow$! (exit : (env : Env A) !$\rightarrow$! treeInvariant env !$\wedge$! stackInvariant env !$\rightarrow$! t ) !$\rightarrow$! t +findP env Cond exit = findP-c (vart env) env Cond exit where + findP-c : {n m : Level} {A : Set n} {t : Set m} !$\rightarrow$! (tree : bt A) !$\rightarrow$! (env : Env A) + !$\rightarrow$! treeInvariant env !$\wedge$! stackInvariant env + !$\rightarrow$! (exit : (env : Env A) !$\rightarrow$! treeInvariant env !$\wedge$! stackInvariant env !$\rightarrow$! t ) !$\rightarrow$! t + findP-c leaf env Cond exit = exit env Cond + findP-c n@(node key-t value ltree rtree) env Cond exit with <-cmp key-t (varn env) + ... | tri< a !$\neg$!b !$\neg$!c = findP-c ltree record env {vart = ltree ; varl = (n !$\text{::}$! (varl env))} {!!} exit + ... | tri!$\approx$! !$\neg$!a b !$\neg$!c = exit record env {vart = n} {!!} + ... | tri> !$\neg$!a !$\neg$!b c = findP-c rtree record env {vart = rtree ; varl = (n !$\text{::}$! (varl env))} {!!} exit \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/bt_verif/invariant.agda --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/bt_verif/invariant.agda Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,14 @@ +treeInvariant : {n : Level} {A : Set n} → (tree : bt A) → Set +treeInvariant leaf = ⊤ +treeInvariant (node key value leaf leaf) = ⊤ +treeInvariant (node key value leaf n@(node key₁ value₁ t₁ t₂)) = (key < key₁) ∧ treeInvariant n +treeInvariant (node key value n@(node key₁ value₁ t t₁) leaf) = treeInvariant n ∧ (key < key₁) +treeInvariant (node key value n@(node key₁ value₁ t t₁) m@(node key₂ value₂ t₂ t₃)) = treeInvariant n ∧ (key < key₁) ∧ (key₁ < key₂) ∧ treeInvariant m + +stackInvariant : {n : Level} {A : Set n} → (tree : bt A) → (stack : List (bt A)) → Set n +stackInvariant {_} {A} _ [] = Lift _ ⊤ +stackInvariant {_} {A} tree (tree1 ∷ [] ) = tree1 ≡ tree +stackInvariant {_} {A} tree (x ∷ tail @ (node key value leaf right ∷ _) ) = (right ≡ x) ∧ stackInvariant tree tail +stackInvariant {_} {A} tree (x ∷ tail @ (node key value left leaf ∷ _) ) = (left ≡ x) ∧ stackInvariant tree tail +stackInvariant {_} {A} tree (x ∷ tail @ (node key value left right ∷ _ )) = ( (left ≡ x) ∧ stackInvariant tree tail) ∨ ( (right ≡ x) ∧ stackInvariant tree tail) +stackInvariant {_} {A} tree s = Lift _ ⊥ \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/bt_verif/invariant.agda.replaced --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/bt_verif/invariant.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,14 @@ +treeInvariant : {n : Level} {A : Set n} !$\rightarrow$! (tree : bt A) !$\rightarrow$! Set +treeInvariant leaf = !$\top$! +treeInvariant (node key value leaf leaf) = !$\top$! +treeInvariant (node key value leaf n@(node key!$\_{1}$! value!$\_{1}$! t!$\_{1}$! t!$\_{2}$!)) = (key < key!$\_{1}$!) !$\wedge$! treeInvariant n +treeInvariant (node key value n@(node key!$\_{1}$! value!$\_{1}$! t t!$\_{1}$!) leaf) = treeInvariant n !$\wedge$! (key < key!$\_{1}$!) +treeInvariant (node key value n@(node key!$\_{1}$! value!$\_{1}$! t t!$\_{1}$!) m@(node key!$\_{2}$! value!$\_{2}$! t!$\_{2}$! t!$\_{3}$!)) = treeInvariant n !$\wedge$! (key < key!$\_{1}$!) !$\wedge$! (key!$\_{1}$! < key!$\_{2}$!) !$\wedge$! treeInvariant m + +stackInvariant : {n : Level} {A : Set n} !$\rightarrow$! (tree : bt A) !$\rightarrow$! (stack : List (bt A)) !$\rightarrow$! Set n +stackInvariant {_} {A} _ [] = Lift _ !$\top$! +stackInvariant {_} {A} tree (tree1 !$\text{::}$! [] ) = tree1 !$\equiv$! tree +stackInvariant {_} {A} tree (x !$\text{::}$! tail @ (node key value leaf right !$\text{::}$! _) ) = (right !$\equiv$! x) !$\wedge$! stackInvariant tree tail +stackInvariant {_} {A} tree (x !$\text{::}$! tail @ (node key value left leaf !$\text{::}$! _) ) = (left !$\equiv$! x) !$\wedge$! stackInvariant tree tail +stackInvariant {_} {A} tree (x !$\text{::}$! tail @ (node key value left right !$\text{::}$! _ )) = ( (left !$\equiv$! x) !$\wedge$! stackInvariant tree tail) ∨ ( (right !$\equiv$! x) !$\wedge$! stackInvariant tree tail) +stackInvariant {_} {A} tree s = Lift _ !$\bot$! \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/cbc-agda.agda.replaced --- a/Paper/src/cbc-agda.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/cbc-agda.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -5,18 +5,18 @@ record Env : Set where field - varx : @$\mathbb{N}$@ - vary : @$\mathbb{N}$@ + varx : !$\mathbb{N}$! + vary : !$\mathbb{N}$! open Env -plus-com : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (next : Env @$\rightarrow$@ t) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t +plus-com : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (next : Env !$\rightarrow$! t) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t plus-com env next exit with vary env ... | zero = exit (record { varx = varx env ; vary = vary env }) ... | suc y = next (record { varx = suc (varx env) ; vary = y }) -{-@$\#$@ TERMINATING @$\#$@-} -plus-p : {l : Level} {t : Set l} @$\rightarrow$@ (env : Env) @$\rightarrow$@ (exit : Env @$\rightarrow$@ t) @$\rightarrow$@ t -plus-p env exit = plus-com env ( @$\lambda$@ env @$\rightarrow$@ plus-p env exit ) exit +{-!$\#$! TERMINATING !$\#$!-} +plus-p : {l : Level} {t : Set l} !$\rightarrow$! (env : Env) !$\rightarrow$! (exit : Env !$\rightarrow$! t) !$\rightarrow$! t +plus-p env exit = plus-com env ( !$\lambda$! env !$\rightarrow$! plus-p env exit ) exit -plus : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Env -plus x y = plus-p (record { varx = x ; vary = y }) (@$\lambda$@ env @$\rightarrow$@ env) +plus : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! Env +plus x y = plus-p (record { varx = x ; vary = y }) (!$\lambda$! env !$\rightarrow$! env) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/cbc-condition.agda.replaced --- a/Paper/src/cbc-condition.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/cbc-condition.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -3,7 +3,7 @@ s2 : whileTestState sf : whileTestState -whileTestStateP : whileTestState @$\rightarrow$@ Envc @$\rightarrow$@ Set -whileTestStateP s1 env = (vari env @$\equiv$@ 0) @$\wedge$@ (varn env @$\equiv$@ c10 env) -whileTestStateP s2 env = (varn env + vari env @$\equiv$@ c10 env) -whileTestStateP sf env = (vari env @$\equiv$@ c10 env) +whileTestStateP : whileTestState !$\rightarrow$! Envc !$\rightarrow$! Set +whileTestStateP s1 env = (vari env !$\equiv$! 0) !$\wedge$! (varn env !$\equiv$! c10 env) +whileTestStateP s2 env = (varn env + vari env !$\equiv$! c10 env) +whileTestStateP sf env = (vari env !$\equiv$! c10 env) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/cbc-hoare-SoundnessC.agda.replaced --- a/Paper/src/cbc-hoare-SoundnessC.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/cbc-hoare-SoundnessC.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ -whileCallwP : (c : @$\mathbb{N}$@) @$\rightarrow$@ whileTestPCallwP' c +whileCallwP : (c : !$\mathbb{N}$!) !$\rightarrow$! whileTestPCallwP!$\prime$! c whileCallwP c = whileTestPwP {_} {_} c - (@$\lambda$@ env s @$\rightarrow$@ loopHelper c (record { c10 = c ; varn = c ; vari = zero }) refl +zero) + (!$\lambda$! env s !$\rightarrow$! loopHelper c (record { c10 = c ; varn = c ; vari = zero }) refl +zero) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/cbc-hoare-loop.agda.replaced --- a/Paper/src/cbc-hoare-loop.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/cbc-hoare-loop.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,15 +1,15 @@ -whileLoopPwP' : {l : Level} {t : Set l} @$\rightarrow$@ (n : @$\mathbb{N}$@) @$\rightarrow$@ (env : Envc ) - @$\rightarrow$@ (n @$\equiv$@ varn env) @$\rightarrow$@ whileTestStateP s2 env - @$\rightarrow$@ (next : (env : Envc ) @$\rightarrow$@ (pred n @$\equiv$@ varn env) @$\rightarrow$@ whileTestStateP s2 env @$\rightarrow$@ t) - @$\rightarrow$@ (exit : (env : Envc ) @$\rightarrow$@ whileTestStateP sf env @$\rightarrow$@ t) @$\rightarrow$@ t -whileLoopPwP' zero env refl refl _ exit = exit env refl -whileLoopPwP' (suc n) env refl refl next _ = +whileLoopPwP!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! (n : !$\mathbb{N}$!) !$\rightarrow$! (env : Envc ) + !$\rightarrow$! (n !$\equiv$! varn env) !$\rightarrow$! whileTestStateP s2 env + !$\rightarrow$! (next : (env : Envc ) !$\rightarrow$! (pred n !$\equiv$! varn env) !$\rightarrow$! whileTestStateP s2 env !$\rightarrow$! t) + !$\rightarrow$! (exit : (env : Envc ) !$\rightarrow$! whileTestStateP sf env !$\rightarrow$! t) !$\rightarrow$! t +whileLoopPwP!$\prime$! zero env refl refl _ exit = exit env refl +whileLoopPwP!$\prime$! (suc n) env refl refl next _ = next (record env {varn = pred (varn env) ; vari = suc (vari env) }) refl (+-suc n (vari env)) -loopPwP' : {l : Level} {t : Set l} @$\rightarrow$@ (n : @$\mathbb{N}$@) @$\rightarrow$@ (env : Envc ) - @$\rightarrow$@ (n @$\equiv$@ varn env) @$\rightarrow$@ whileTestStateP s2 env - @$\rightarrow$@ (exit : (env : Envc ) @$\rightarrow$@ whileTestStateP sf env @$\rightarrow$@ t) @$\rightarrow$@ t -loopPwP' zero env refl refl exit = exit env refl -loopPwP' (suc n) env refl refl exit - = whileLoopPwP' (suc n) env refl refl (@$\lambda$@ env x y @$\rightarrow$@ loopPwP' n env x y exit) exit +loopPwP!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! (n : !$\mathbb{N}$!) !$\rightarrow$! (env : Envc ) + !$\rightarrow$! (n !$\equiv$! varn env) !$\rightarrow$! whileTestStateP s2 env + !$\rightarrow$! (exit : (env : Envc ) !$\rightarrow$! whileTestStateP sf env !$\rightarrow$! t) !$\rightarrow$! t +loopPwP!$\prime$! zero env refl refl exit = exit env refl +loopPwP!$\prime$! (suc n) env refl refl exit + = whileLoopPwP!$\prime$! (suc n) env refl refl (!$\lambda$! env x y !$\rightarrow$! loopPwP!$\prime$! n env x y exit) exit diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/cbc-hoare-loophelper.agda.replaced --- a/Paper/src/cbc-hoare-loophelper.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/cbc-hoare-loophelper.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,5 +1,5 @@ -loopHelper : (n : @$\mathbb{N}$@) @$\rightarrow$@ (env : Envc ) @$\rightarrow$@ (eq : varn env @$\equiv$@ n) @$\rightarrow$@ (seq : whileTestStateP s2 env) - @$\rightarrow$@ loopPwP' n env (sym eq) seq (@$\lambda$@ env@$\_{1}$@ x @$\rightarrow$@ (vari env@$\_{1}$@ @$\equiv$@ c10 env@$\_{1}$@)) +loopHelper : (n : !$\mathbb{N}$!) !$\rightarrow$! (env : Envc ) !$\rightarrow$! (eq : varn env !$\equiv$! n) !$\rightarrow$! (seq : whileTestStateP s2 env) + !$\rightarrow$! loopPwP!$\prime$! n env (sym eq) seq (!$\lambda$! env!$\_{1}$! x !$\rightarrow$! (vari env!$\_{1}$! !$\equiv$! c10 env!$\_{1}$!)) loopHelper zero env eq refl rewrite eq = refl loopHelper (suc n) env refl refl = loopHelper n (record { c10 = suc (n + vari env) ; varn = n ; vari = suc (vari env) }) refl (+-suc n (vari env)) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/cbc-hoare-prim.agda.replaced --- a/Paper/src/cbc-hoare-prim.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/cbc-hoare-prim.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -whileTestPwP : {l : Level} {t : Set l} @$\rightarrow$@ (c10 : @$\mathbb{N}$@) @$\rightarrow$@ ((env : Envc ) @$\rightarrow$@ whileTestStateP s1 env @$\rightarrow$@ t) @$\rightarrow$@ t +whileTestPwP : {l : Level} {t : Set l} !$\rightarrow$! (c10 : !$\mathbb{N}$!) !$\rightarrow$! ((env : Envc ) !$\rightarrow$! whileTestStateP s1 env !$\rightarrow$! t) !$\rightarrow$! t whileTestPwP c10 next = next env record { pi1 = refl ; pi2 = refl } where env : Envc - env = whileTestP c10 ( @$\lambda$@ env @$\rightarrow$@ env ) + env = whileTestP c10 ( !$\lambda$! env !$\rightarrow$! env ) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/cbc-hoare-soundness.agda.replaced --- a/Paper/src/cbc-hoare-soundness.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/cbc-hoare-soundness.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,13 +1,13 @@ -whileCallwP : (c : @$\mathbb{N}$@) @$\rightarrow$@ whileTestPCallwP' c +whileCallwP : (c : !$\mathbb{N}$!) !$\rightarrow$! whileTestPCallwP!$\prime$! c whileCallwP c = whileTestPwP {_} {_} c - (@$\lambda$@ env s @$\rightarrow$@ loopPwP' (c10 env) env (sym (pi2 s)) (conv env s) {!!}) + (!$\lambda$! env s !$\rightarrow$! loopPwP!$\prime$! (c10 env) env (sym (pi2 s)) (conv env s) {!!}) --- Goal: (env@$\_{1}$@ : Envc) @$\rightarrow$@ --- vari env@$\_{1}$@ @$\equiv$@ c10 env@$\_{1}$@ @$\rightarrow$@ --- loopPwP' c (whileTestP c (@$\lambda$@ env@$\_{2}$@ @$\rightarrow$@ env@$\_{2}$@)) refl +zero --- (@$\lambda$@ env@$\_{2}$@ s@$\_{1}$@ @$\rightarrow$@ vari env@$\_{2}$@ @$\equiv$@ c10 env@$\_{2}$@) +-- Goal: (env!$\_{1}$! : Envc) !$\rightarrow$! +-- vari env!$\_{1}$! !$\equiv$! c10 env!$\_{1}$! !$\rightarrow$! +-- loopPwP!$\prime$! c (whileTestP c (!$\lambda$! env!$\_{2}$! !$\rightarrow$! env!$\_{2}$!)) refl +zero +-- (!$\lambda$! env!$\_{2}$! s!$\_{1}$! !$\rightarrow$! vari env!$\_{2}$! !$\equiv$! c10 env!$\_{2}$!) -- ———————————————————————— --- s : (vari env @$\equiv$@ 0) @$\wedge$@ (varn env @$\equiv$@ c10 env) +-- s : (vari env !$\equiv$! 0) !$\wedge$! (varn env !$\equiv$! c10 env) -- env : Envc --- c : @$\mathbb{N}$@ +-- c : !$\mathbb{N}$! diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/cbc-hoare-while.agda.replaced --- a/Paper/src/cbc-hoare-while.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/cbc-hoare-while.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,6 +1,6 @@ -whileTestPCallwP' : (c : @$\mathbb{N}$@ ) @$\rightarrow$@ Set -whileTestPCallwP' c = whileTestPwP {_} {_} c (@$\lambda$@ env s @$\rightarrow$@ loopPwP' (varn env) env refl (conv env s) ( @$\lambda$@ env s @$\rightarrow$@ vari env @$\equiv$@ c10 env ) ) +whileTestPCallwP!$\prime$! : (c : !$\mathbb{N}$! ) !$\rightarrow$! Set +whileTestPCallwP!$\prime$! c = whileTestPwP {_} {_} c (!$\lambda$! env s !$\rightarrow$! loopPwP!$\prime$! (varn env) env refl (conv env s) ( !$\lambda$! env s !$\rightarrow$! vari env !$\equiv$! c10 env ) ) --- conv : (env : Envc ) @$\rightarrow$@ (vari env @$\equiv$@ 0) @$\wedge$@ (varn env @$\equiv$@ c10 env) @$\rightarrow$@ varn env + vari env @$\equiv$@ c10 env +-- conv : (env : Envc ) !$\rightarrow$! (vari env !$\equiv$! 0) !$\wedge$! (varn env !$\equiv$! c10 env) !$\rightarrow$! varn env + vari env !$\equiv$! c10 env -- conv e record { pi1 = refl ; pi2 = refl } = +zero diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/cbc-hoare.agda.replaced --- a/Paper/src/cbc-hoare.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/cbc-hoare.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,14 +1,14 @@ -whileTestPwP : {l : Level} {t : Set l} @$\rightarrow$@ (c10 : @$\mathbb{N}$@) @$\rightarrow$@ ((env : Envc ) @$\rightarrow$@ whileTestStateP s1 env @$\rightarrow$@ t) @$\rightarrow$@ t +whileTestPwP : {l : Level} {t : Set l} !$\rightarrow$! (c10 : !$\mathbb{N}$!) !$\rightarrow$! ((env : Envc ) !$\rightarrow$! whileTestStateP s1 env !$\rightarrow$! t) !$\rightarrow$! t whileTestPwP c10 next = next env record { pi1 = refl ; pi2 = refl } where env : Envc - env = whileTestP c10 ( @$\lambda$@ env @$\rightarrow$@ env ) + env = whileTestP c10 ( !$\lambda$! env !$\rightarrow$! env ) -loopPwP' : {l : Level} {t : Set l} @$\rightarrow$@ (n : @$\mathbb{N}$@) @$\rightarrow$@ (env : Envc ) @$\rightarrow$@ (n @$\equiv$@ varn env) @$\rightarrow$@ whileTestStateP s2 env @$\rightarrow$@ (exit : (env : Envc ) @$\rightarrow$@ whileTestStateP sf env @$\rightarrow$@ t) @$\rightarrow$@ t -loopPwP' zero env refl refl exit = exit env refl -loopPwP' (suc n) env refl refl exit = whileLoopPwP' (suc n) env refl refl (@$\lambda$@ env x y @$\rightarrow$@ loopPwP' n env x y exit) exit +loopPwP!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! (n : !$\mathbb{N}$!) !$\rightarrow$! (env : Envc ) !$\rightarrow$! (n !$\equiv$! varn env) !$\rightarrow$! whileTestStateP s2 env !$\rightarrow$! (exit : (env : Envc ) !$\rightarrow$! whileTestStateP sf env !$\rightarrow$! t) !$\rightarrow$! t +loopPwP!$\prime$! zero env refl refl exit = exit env refl +loopPwP!$\prime$! (suc n) env refl refl exit = whileLoopPwP!$\prime$! (suc n) env refl refl (!$\lambda$! env x y !$\rightarrow$! loopPwP!$\prime$! n env x y exit) exit -whileTestPCallwP' : (c : @$\mathbb{N}$@ ) @$\rightarrow$@ Set -whileTestPCallwP' c = whileTestPwP {_} {_} c (@$\lambda$@ env s @$\rightarrow$@ loopPwP' (varn env) env refl (conv env s) ( @$\lambda$@ env s @$\rightarrow$@ vari env @$\equiv$@ c10 env ) ) +whileTestPCallwP!$\prime$! : (c : !$\mathbb{N}$! ) !$\rightarrow$! Set +whileTestPCallwP!$\prime$! c = whileTestPwP {_} {_} c (!$\lambda$! env s !$\rightarrow$! loopPwP!$\prime$! (varn env) env refl (conv env s) ( !$\lambda$! env s !$\rightarrow$! vari env !$\equiv$! c10 env ) ) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/cong.agda.replaced --- a/Paper/src/cong.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/cong.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,2 +1,2 @@ -cong : @$\forall$@ (f : A @$\rightarrow$@ B) {x y} @$\rightarrow$@ x @$\equiv$@ y @$\rightarrow$@ f x @$\equiv$@ f y +cong : !$\forall$! (f : A !$\rightarrow$! B) {x y} !$\rightarrow$! x !$\equiv$! y !$\rightarrow$! f x !$\equiv$! f y cong f refl = refl diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/env.agda.replaced --- a/Paper/src/env.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/env.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,8 +1,8 @@ record Envc : Set where field - vari : @$\mathbb{N}$@ - varn : @$\mathbb{N}$@ - c10 : @$\mathbb{N}$@ + vari : !$\mathbb{N}$! + varn : !$\mathbb{N}$! + c10 : !$\mathbb{N}$! -makeEnv : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Envc +makeEnv : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! Envc makeEnv i n c = record { vari = i ; varn = n ; c10 = c } diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/function.agda.replaced --- a/Paper/src/function.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/function.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -_-_ :@$\mathbb{N}$@ @$\rightarrow$@@$\mathbb{N}$@ @$\rightarrow$@@$\mathbb{N}$@ +_-_ :!$\mathbb{N}$! !$\rightarrow$!!$\mathbb{N}$! !$\rightarrow$!!$\mathbb{N}$! x - zero = x zero - _ = zero (suc x) - (suc y) = x - y diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/gears-while.agda.replaced --- a/Paper/src/gears-while.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/gears-while.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,51 +1,51 @@ -whileTest : {l : Level} {t : Set l} @$\rightarrow$@ {c10 : @$\mathbb{N}$@ } @$\rightarrow$@ (Code : (env : Env) @$\rightarrow$@ - ((vari env) @$\equiv$@ 0) @$\wedge$@ ((varn env) @$\equiv$@ c10) @$\rightarrow$@ t) @$\rightarrow$@ t +whileTest : {l : Level} {t : Set l} !$\rightarrow$! {c10 : !$\mathbb{N}$! } !$\rightarrow$! (Code : (env : Env) !$\rightarrow$! + ((vari env) !$\equiv$! 0) !$\wedge$! ((varn env) !$\equiv$! c10) !$\rightarrow$! t) !$\rightarrow$! t whileTest {_} {_} {c10} next = next env proof2 where env : Env env = record {vari = 0 ; varn = c10} - proof2 : ((vari env) @$\equiv$@ 0) @$\wedge$@ ((varn env) @$\equiv$@ c10) + proof2 : ((vari env) !$\equiv$! 0) !$\wedge$! ((varn env) !$\equiv$! c10) proof2 = record {pi1 = refl ; pi2 = refl} -conversion1 : {l : Level} {t : Set l } @$\rightarrow$@ (env : Env) @$\rightarrow$@ {c10 : @$\mathbb{N}$@ } @$\rightarrow$@ ((vari env) @$\equiv$@ 0) @$\wedge$@ ((varn env) @$\equiv$@ c10) - @$\rightarrow$@ (Code : (env1 : Env) @$\rightarrow$@ (varn env1 + vari env1 @$\equiv$@ c10) @$\rightarrow$@ t) @$\rightarrow$@ t +conversion1 : {l : Level} {t : Set l } !$\rightarrow$! (env : Env) !$\rightarrow$! {c10 : !$\mathbb{N}$! } !$\rightarrow$! ((vari env) !$\equiv$! 0) !$\wedge$! ((varn env) !$\equiv$! c10) + !$\rightarrow$! (Code : (env1 : Env) !$\rightarrow$! (varn env1 + vari env1 !$\equiv$! c10) !$\rightarrow$! t) !$\rightarrow$! t conversion1 env {c10} p1 next = next env proof4 where - proof4 : varn env + vari env @$\equiv$@ c10 - proof4 = let open @$\equiv$@-Reasoning in + proof4 : varn env + vari env !$\equiv$! c10 + proof4 = let open !$\equiv$!-Reasoning in begin varn env + vari env - @$\equiv$@@$\langle$@ cong ( @$\lambda$@ n @$\rightarrow$@ n + vari env ) (pi2 p1 ) @$\rangle$@ + !$\equiv$!!$\langle$! cong ( !$\lambda$! n !$\rightarrow$! n + vari env ) (pi2 p1 ) !$\rangle$! c10 + vari env - @$\equiv$@@$\langle$@ cong ( @$\lambda$@ n @$\rightarrow$@ c10 + n ) (pi1 p1 ) @$\rangle$@ + !$\equiv$!!$\langle$! cong ( !$\lambda$! n !$\rightarrow$! c10 + n ) (pi1 p1 ) !$\rangle$! c10 + 0 - @$\equiv$@@$\langle$@ +-sym {c10} {0} @$\rangle$@ + !$\equiv$!!$\langle$! +-sym {c10} {0} !$\rangle$! c10 - @$\blacksquare$@ + !$\blacksquare$! -{-@$\#$@ TERMINATING @$\#$@-} -whileLoop : {l : Level} {t : Set l} @$\rightarrow$@ (env : Env) @$\rightarrow$@ {c10 : @$\mathbb{N}$@ } @$\rightarrow$@ ((varn env) + (vari env) @$\equiv$@ c10) @$\rightarrow$@ (Code : Env @$\rightarrow$@ t) @$\rightarrow$@ t -whileLoop env proof next with ( suc zero @$\leq$@? (varn env) ) +{-!$\#$! TERMINATING !$\#$!-} +whileLoop : {l : Level} {t : Set l} !$\rightarrow$! (env : Env) !$\rightarrow$! {c10 : !$\mathbb{N}$! } !$\rightarrow$! ((varn env) + (vari env) !$\equiv$! c10) !$\rightarrow$! (Code : Env !$\rightarrow$! t) !$\rightarrow$! t +whileLoop env proof next with ( suc zero !$\leq$!? (varn env) ) whileLoop env proof next | no p = next env whileLoop env {c10} proof next | yes p = whileLoop env1 (proof3 p ) next where env1 = record {varn = (varn env) - 1 ; vari = (vari env) + 1} - 1<0 : 1 @$\leq$@ zero @$\rightarrow$@ @$\bot$@ + 1<0 : 1 !$\leq$! zero !$\rightarrow$! !$\bot$! 1<0 () - proof3 : (suc zero @$\leq$@ (varn env)) @$\rightarrow$@ varn env1 + vari env1 @$\equiv$@ c10 - proof3 (s@$\leq$@s lt) with varn env - proof3 (s@$\leq$@s z@$\leq$@n) | zero = @$\bot$@-elim (1<0 p) - proof3 (s@$\leq$@s (z@$\leq$@n {n'}) ) | suc n = let open @$\equiv$@-Reasoning in + proof3 : (suc zero !$\leq$! (varn env)) !$\rightarrow$! varn env1 + vari env1 !$\equiv$! c10 + proof3 (s!$\leq$!s lt) with varn env + proof3 (s!$\leq$!s z!$\leq$!n) | zero = !$\bot$!-elim (1<0 p) + proof3 (s!$\leq$!s (z!$\leq$!n {n!$\prime$!}) ) | suc n = let open !$\equiv$!-Reasoning in begin - n' + (vari env + 1) - @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ n' + z ) ( +-sym {vari env} {1} ) @$\rangle$@ - n' + (1 + vari env ) - @$\equiv$@@$\langle$@ sym ( +-assoc (n') 1 (vari env) ) @$\rangle$@ - (n' + 1) + vari env - @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ z + vari env ) +1@$\equiv$@suc @$\rangle$@ - (suc n' ) + vari env - @$\equiv$@@$\langle$@@$\rangle$@ + n!$\prime$! + (vari env + 1) + !$\equiv$!!$\langle$! cong ( !$\lambda$! z !$\rightarrow$! n!$\prime$! + z ) ( +-sym {vari env} {1} ) !$\rangle$! + n!$\prime$! + (1 + vari env ) + !$\equiv$!!$\langle$! sym ( +-assoc (n!$\prime$!) 1 (vari env) ) !$\rangle$! + (n!$\prime$! + 1) + vari env + !$\equiv$!!$\langle$! cong ( !$\lambda$! z !$\rightarrow$! z + vari env ) +1!$\equiv$!suc !$\rangle$! + (suc n!$\prime$! ) + vari env + !$\equiv$!!$\langle$!!$\rangle$! varn env + vari env - @$\equiv$@@$\langle$@ proof @$\rangle$@ + !$\equiv$!!$\langle$! proof !$\rangle$! c10 - @$\blacksquare$@ + !$\blacksquare$! diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/gears.agda.replaced --- a/Paper/src/gears.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/gears.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,2 +1,2 @@ -proofGears : {c10 : @$\mathbb{N}$@ } @$\rightarrow$@ Set -proofGears {c10} = whileTest {_} {_} {c10} (@$\lambda$@ n p1 @$\rightarrow$@ conversion1 n p1 (@$\lambda$@ n1 p2 @$\rightarrow$@ whileLoop' n1 p2 (@$\lambda$@ n2 @$\rightarrow$@ ( vari n2 @$\equiv$@ c10 )))) +proofGears : {c10 : !$\mathbb{N}$! } !$\rightarrow$! Set +proofGears {c10} = whileTest {_} {_} {c10} (!$\lambda$! n p1 !$\rightarrow$! conversion1 n p1 (!$\lambda$! n1 p2 !$\rightarrow$! whileLoop!$\prime$! n1 p2 (!$\lambda$! n2 !$\rightarrow$! ( vari n2 !$\equiv$! c10 )))) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/nat.agda.replaced --- a/Paper/src/nat.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/nat.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ -data @$\mathbb{N}$@ : Set where - zero : @$\mathbb{N}$@ - suc : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ +data !$\mathbb{N}$! : Set where + zero : !$\mathbb{N}$! + suc : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/record.agda.replaced --- a/Paper/src/record.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/record.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ record Env : Set where field - varn : @$\mathbb{N}$@ - vari : @$\mathbb{N}$@ + varn : !$\mathbb{N}$! + vari : !$\mathbb{N}$! diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/redBlackTreeTest.agda.replaced --- a/Paper/src/redBlackTreeTest.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/redBlackTreeTest.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -13,171 +13,171 @@ -- tests -putTree1 : {n m : Level } {a k : Set n} {t : Set m} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ k @$\rightarrow$@ a @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ t) @$\rightarrow$@ t +putTree1 : {n m : Level } {a k : Set n} {t : Set m} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! k !$\rightarrow$! a !$\rightarrow$! (RedBlackTree {n} {m} {t} a k !$\rightarrow$! t) !$\rightarrow$! t putTree1 {n} {m} {a} {k} {t} tree k1 value next with (root tree) ... | Nothing = next (record tree {root = Just (leafNode k1 value) }) -... | Just n2 = clearSingleLinkedStack (nodeStack tree) (\ s @$\rightarrow$@ findNode tree s (leafNode k1 value) n2 (\ tree1 s n1 @$\rightarrow$@ replaceNode tree1 s n1 next)) +... | Just n2 = clearSingleLinkedStack (nodeStack tree) (\ s !$\rightarrow$! findNode tree s (leafNode k1 value) n2 (\ tree1 s n1 !$\rightarrow$! replaceNode tree1 s n1 next)) open import Relation.Binary.PropositionalEquality open import Relation.Binary.Core open import Function -check1 : {m : Level } (n : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)) @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Bool {m} +check1 : {m : Level } (n : Maybe (Node !$\mathbb{N}$! !$\mathbb{N}$!)) !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! Bool {m} check1 Nothing _ = False check1 (Just n) x with Data.Nat.compare (value n) x ... | equal _ = True ... | _ = False -check2 : {m : Level } (n : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)) @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Bool {m} +check2 : {m : Level } (n : Maybe (Node !$\mathbb{N}$! !$\mathbb{N}$!)) !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! Bool {m} check2 Nothing _ = False check2 (Just n) x with compare2 (value n) x ... | EQ = True ... | _ = False -test1 : putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero} ) 1 1 ( \t @$\rightarrow$@ getRedBlackTree t 1 ( \t x @$\rightarrow$@ check2 x 1 @$\equiv$@ True )) +test1 : putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$! {Set Level.zero} ) 1 1 ( \t !$\rightarrow$! getRedBlackTree t 1 ( \t x !$\rightarrow$! check2 x 1 !$\equiv$! True )) test1 = refl -test2 : putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero} ) 1 1 ( - \t @$\rightarrow$@ putTree1 t 2 2 ( - \t @$\rightarrow$@ getRedBlackTree t 1 ( - \t x @$\rightarrow$@ check2 x 1 @$\equiv$@ True ))) +test2 : putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$! {Set Level.zero} ) 1 1 ( + \t !$\rightarrow$! putTree1 t 2 2 ( + \t !$\rightarrow$! getRedBlackTree t 1 ( + \t x !$\rightarrow$! check2 x 1 !$\equiv$! True ))) test2 = refl -open @$\equiv$@-Reasoning -test3 : putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero}) 1 1 - $ \t @$\rightarrow$@ putTree1 t 2 2 - $ \t @$\rightarrow$@ putTree1 t 3 3 - $ \t @$\rightarrow$@ putTree1 t 4 4 - $ \t @$\rightarrow$@ getRedBlackTree t 1 - $ \t x @$\rightarrow$@ check2 x 1 @$\equiv$@ True +open !$\equiv$!-Reasoning +test3 : putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$! {Set Level.zero}) 1 1 + $ \t !$\rightarrow$! putTree1 t 2 2 + $ \t !$\rightarrow$! putTree1 t 3 3 + $ \t !$\rightarrow$! putTree1 t 4 4 + $ \t !$\rightarrow$! getRedBlackTree t 1 + $ \t x !$\rightarrow$! check2 x 1 !$\equiv$! True test3 = begin check2 (Just (record {key = 1 ; value = 1 ; color = Black ; left = Nothing ; right = Just (leafNode 2 2)})) 1 - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! True - @$\blacksquare$@ + !$\blacksquare$! -test31 = putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ ) 1 1 - $ \t @$\rightarrow$@ putTree1 t 2 2 - $ \t @$\rightarrow$@ putTree1 t 3 3 - $ \t @$\rightarrow$@ putTree1 t 4 4 - $ \t @$\rightarrow$@ getRedBlackTree t 4 - $ \t x @$\rightarrow$@ x +test31 = putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$! ) 1 1 + $ \t !$\rightarrow$! putTree1 t 2 2 + $ \t !$\rightarrow$! putTree1 t 3 3 + $ \t !$\rightarrow$! putTree1 t 4 4 + $ \t !$\rightarrow$! getRedBlackTree t 4 + $ \t x !$\rightarrow$! x --- test5 : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@) -test5 = putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ ) 4 4 - $ \t @$\rightarrow$@ putTree1 t 6 6 - $ \t0 @$\rightarrow$@ clearSingleLinkedStack (nodeStack t0) - $ \s @$\rightarrow$@ findNode1 t0 s (leafNode 3 3) ( root t0 ) - $ \t1 s n1 @$\rightarrow$@ replaceNode t1 s n1 - $ \t @$\rightarrow$@ getRedBlackTree t 3 - -- $ \t x @$\rightarrow$@ SingleLinkedStack.top (stack s) - -- $ \t x @$\rightarrow$@ n1 - $ \t x @$\rightarrow$@ root t +-- test5 : Maybe (Node !$\mathbb{N}$! !$\mathbb{N}$!) +test5 = putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$! ) 4 4 + $ \t !$\rightarrow$! putTree1 t 6 6 + $ \t0 !$\rightarrow$! clearSingleLinkedStack (nodeStack t0) + $ \s !$\rightarrow$! findNode1 t0 s (leafNode 3 3) ( root t0 ) + $ \t1 s n1 !$\rightarrow$! replaceNode t1 s n1 + $ \t !$\rightarrow$! getRedBlackTree t 3 + -- $ \t x !$\rightarrow$! SingleLinkedStack.top (stack s) + -- $ \t x !$\rightarrow$! n1 + $ \t x !$\rightarrow$! root t where - findNode1 : {n m : Level } {a k : Set n} {t : Set m} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ (Node a k) @$\rightarrow$@ (Maybe (Node a k)) @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Node a k @$\rightarrow$@ t) @$\rightarrow$@ t + findNode1 : {n m : Level } {a k : Set n} {t : Set m} !$\rightarrow$! RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! (Node a k) !$\rightarrow$! (Maybe (Node a k)) !$\rightarrow$! (RedBlackTree {n} {m} {t} a k !$\rightarrow$! SingleLinkedStack (Node a k) !$\rightarrow$! Node a k !$\rightarrow$! t) !$\rightarrow$! t findNode1 t s n1 Nothing next = next t s n1 findNode1 t s n1 ( Just n2 ) next = findNode t s n1 n2 next --- test51 : putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} {_} {Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero} ) 1 1 $ \t @$\rightarrow$@ --- putTree1 t 2 2 $ \t @$\rightarrow$@ putTree1 t 3 3 $ \t @$\rightarrow$@ root t @$\equiv$@ Just (record { key = 1; value = 1; left = Just (record { key = 2 ; value = 2 } ); right = Nothing} ) +-- test51 : putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} {_} {Maybe (Node !$\mathbb{N}$! !$\mathbb{N}$!)} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$! {Set Level.zero} ) 1 1 $ \t !$\rightarrow$! +-- putTree1 t 2 2 $ \t !$\rightarrow$! putTree1 t 3 3 $ \t !$\rightarrow$! root t !$\equiv$! Just (record { key = 1; value = 1; left = Just (record { key = 2 ; value = 2 } ); right = Nothing} ) -- test51 = refl -test6 : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@) -test6 = root (createEmptyRedBlackTree@$\mathbb{N}$@ {_} @$\mathbb{N}$@ {Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)}) +test6 : Maybe (Node !$\mathbb{N}$! !$\mathbb{N}$!) +test6 = root (createEmptyRedBlackTree!$\mathbb{N}$! {_} !$\mathbb{N}$! {Maybe (Node !$\mathbb{N}$! !$\mathbb{N}$!)}) -test7 : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@) -test7 = clearSingleLinkedStack (nodeStack tree2) (\ s @$\rightarrow$@ replaceNode tree2 s n2 (\ t @$\rightarrow$@ root t)) +test7 : Maybe (Node !$\mathbb{N}$! !$\mathbb{N}$!) +test7 = clearSingleLinkedStack (nodeStack tree2) (\ s !$\rightarrow$! replaceNode tree2 s n2 (\ t !$\rightarrow$! root t)) where - tree2 = createEmptyRedBlackTree@$\mathbb{N}$@ {_} @$\mathbb{N}$@ {Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)} + tree2 = createEmptyRedBlackTree!$\mathbb{N}$! {_} !$\mathbb{N}$! {Maybe (Node !$\mathbb{N}$! !$\mathbb{N}$!)} k1 = 1 n2 = leafNode 0 0 value1 = 1 -test8 : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@) -test8 = putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@) 1 1 - $ \t @$\rightarrow$@ putTree1 t 2 2 (\ t @$\rightarrow$@ root t) +test8 : Maybe (Node !$\mathbb{N}$! !$\mathbb{N}$!) +test8 = putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$!) 1 1 + $ \t !$\rightarrow$! putTree1 t 2 2 (\ t !$\rightarrow$! root t) -test9 : putRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero} ) 1 1 ( \t @$\rightarrow$@ getRedBlackTree t 1 ( \t x @$\rightarrow$@ check2 x 1 @$\equiv$@ True )) +test9 : putRedBlackTree {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$! {Set Level.zero} ) 1 1 ( \t !$\rightarrow$! getRedBlackTree t 1 ( \t x !$\rightarrow$! check2 x 1 !$\equiv$! True )) test9 = refl -test10 : putRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero} ) 1 1 ( - \t @$\rightarrow$@ putRedBlackTree t 2 2 ( - \t @$\rightarrow$@ getRedBlackTree t 1 ( - \t x @$\rightarrow$@ check2 x 1 @$\equiv$@ True ))) +test10 : putRedBlackTree {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$! {Set Level.zero} ) 1 1 ( + \t !$\rightarrow$! putRedBlackTree t 2 2 ( + \t !$\rightarrow$! getRedBlackTree t 1 ( + \t x !$\rightarrow$! check2 x 1 !$\equiv$! True ))) test10 = refl -test11 = putRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@) 1 1 - $ \t @$\rightarrow$@ putRedBlackTree t 2 2 - $ \t @$\rightarrow$@ putRedBlackTree t 3 3 - $ \t @$\rightarrow$@ getRedBlackTree t 2 - $ \t x @$\rightarrow$@ root t +test11 = putRedBlackTree {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (createEmptyRedBlackTree!$\mathbb{N}$! !$\mathbb{N}$!) 1 1 + $ \t !$\rightarrow$! putRedBlackTree t 2 2 + $ \t !$\rightarrow$! putRedBlackTree t 3 3 + $ \t !$\rightarrow$! getRedBlackTree t 2 + $ \t x !$\rightarrow$! root t -redBlackInSomeState : { m : Level } (a : Set Level.zero) (n : Maybe (Node a @$\mathbb{N}$@)) {t : Set m} @$\rightarrow$@ RedBlackTree {Level.zero} {m} {t} a @$\mathbb{N}$@ +redBlackInSomeState : { m : Level } (a : Set Level.zero) (n : Maybe (Node a !$\mathbb{N}$!)) {t : Set m} !$\rightarrow$! RedBlackTree {Level.zero} {m} {t} a !$\mathbb{N}$! redBlackInSomeState {m} a n {t} = record { root = n ; nodeStack = emptySingleLinkedStack ; compare = compare2 } --- compare2 : (x y : @$\mathbb{N}$@ ) @$\rightarrow$@ compareresult +-- compare2 : (x y : !$\mathbb{N}$! ) !$\rightarrow$! compareresult -- compare2 zero zero = eq -- compare2 (suc _) zero = gt -- compare2 zero (suc _) = lt -- compare2 (suc x) (suc y) = compare2 x y -putTest1Lemma2 : (k : @$\mathbb{N}$@) @$\rightarrow$@ compare2 k k @$\equiv$@ EQ +putTest1Lemma2 : (k : !$\mathbb{N}$!) !$\rightarrow$! compare2 k k !$\equiv$! EQ putTest1Lemma2 zero = refl putTest1Lemma2 (suc k) = putTest1Lemma2 k -putTest1Lemma1 : (x y : @$\mathbb{N}$@) @$\rightarrow$@ compare@$\mathbb{N}$@ x y @$\equiv$@ compare2 x y +putTest1Lemma1 : (x y : !$\mathbb{N}$!) !$\rightarrow$! compare!$\mathbb{N}$! x y !$\equiv$! compare2 x y putTest1Lemma1 zero zero = refl putTest1Lemma1 (suc m) zero = refl putTest1Lemma1 zero (suc n) = refl putTest1Lemma1 (suc m) (suc n) with Data.Nat.compare m n putTest1Lemma1 (suc .m) (suc .(Data.Nat.suc m + k)) | less m k = lemma1 m where - lemma1 : (m : @$\mathbb{N}$@) @$\rightarrow$@ LT @$\equiv$@ compare2 m (@$\mathbb{N}$@.suc (m + k)) + lemma1 : (m : !$\mathbb{N}$!) !$\rightarrow$! LT !$\equiv$! compare2 m (!$\mathbb{N}$!.suc (m + k)) lemma1 zero = refl lemma1 (suc y) = lemma1 y putTest1Lemma1 (suc .m) (suc .m) | equal m = lemma1 m where - lemma1 : (m : @$\mathbb{N}$@) @$\rightarrow$@ EQ @$\equiv$@ compare2 m m + lemma1 : (m : !$\mathbb{N}$!) !$\rightarrow$! EQ !$\equiv$! compare2 m m lemma1 zero = refl lemma1 (suc y) = lemma1 y putTest1Lemma1 (suc .(Data.Nat.suc m + k)) (suc .m) | greater m k = lemma1 m where - lemma1 : (m : @$\mathbb{N}$@) @$\rightarrow$@ GT @$\equiv$@ compare2 (@$\mathbb{N}$@.suc (m + k)) m + lemma1 : (m : !$\mathbb{N}$!) !$\rightarrow$! GT !$\equiv$! compare2 (!$\mathbb{N}$!.suc (m + k)) m lemma1 zero = refl lemma1 (suc y) = lemma1 y -putTest1Lemma3 : (k : @$\mathbb{N}$@) @$\rightarrow$@ compare@$\mathbb{N}$@ k k @$\equiv$@ EQ +putTest1Lemma3 : (k : !$\mathbb{N}$!) !$\rightarrow$! compare!$\mathbb{N}$! k k !$\equiv$! EQ putTest1Lemma3 k = trans (putTest1Lemma1 k k) ( putTest1Lemma2 k ) -compareLemma1 : {x y : @$\mathbb{N}$@} @$\rightarrow$@ compare2 x y @$\equiv$@ EQ @$\rightarrow$@ x @$\equiv$@ y +compareLemma1 : {x y : !$\mathbb{N}$!} !$\rightarrow$! compare2 x y !$\equiv$! EQ !$\rightarrow$! x !$\equiv$! y compareLemma1 {zero} {zero} refl = refl compareLemma1 {zero} {suc _} () compareLemma1 {suc _} {zero} () -compareLemma1 {suc x} {suc y} eq = cong ( \z @$\rightarrow$@ @$\mathbb{N}$@.suc z ) ( compareLemma1 ( trans lemma2 eq ) ) +compareLemma1 {suc x} {suc y} eq = cong ( \z !$\rightarrow$! !$\mathbb{N}$!.suc z ) ( compareLemma1 ( trans lemma2 eq ) ) where - lemma2 : compare2 (@$\mathbb{N}$@.suc x) (@$\mathbb{N}$@.suc y) @$\equiv$@ compare2 x y + lemma2 : compare2 (!$\mathbb{N}$!.suc x) (!$\mathbb{N}$!.suc y) !$\equiv$! compare2 x y lemma2 = refl -putTest1 :{ m : Level } (n : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)) - @$\rightarrow$@ (k : @$\mathbb{N}$@) (x : @$\mathbb{N}$@) - @$\rightarrow$@ putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (redBlackInSomeState {_} @$\mathbb{N}$@ n {Set Level.zero}) k x - (\ t @$\rightarrow$@ getRedBlackTree t k (\ t x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True)) +putTest1 :{ m : Level } (n : Maybe (Node !$\mathbb{N}$! !$\mathbb{N}$!)) + !$\rightarrow$! (k : !$\mathbb{N}$!) (x : !$\mathbb{N}$!) + !$\rightarrow$! putTree1 {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} (redBlackInSomeState {_} !$\mathbb{N}$! n {Set Level.zero}) k x + (\ t !$\rightarrow$! getRedBlackTree t k (\ t x1 !$\rightarrow$! check2 x1 x !$\equiv$! True)) putTest1 n k x with n ... | Just n1 = lemma2 ( record { top = Nothing } ) where - lemma2 : (s : SingleLinkedStack (Node @$\mathbb{N}$@ @$\mathbb{N}$@) ) @$\rightarrow$@ putTree1 (record { root = Just n1 ; nodeStack = s ; compare = compare2 }) k x (@$\lambda$@ t @$\rightarrow$@ - GetRedBlackTree.checkNode t k (@$\lambda$@ t@$\_{1}$@ x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True) (root t)) + lemma2 : (s : SingleLinkedStack (Node !$\mathbb{N}$! !$\mathbb{N}$!) ) !$\rightarrow$! putTree1 (record { root = Just n1 ; nodeStack = s ; compare = compare2 }) k x (!$\lambda$! t !$\rightarrow$! + GetRedBlackTree.checkNode t k (!$\lambda$! t!$\_{1}$! x1 !$\rightarrow$! check2 x1 x !$\equiv$! True) (root t)) lemma2 s with compare2 k (key n1) ... | EQ = lemma3 {!!} where - lemma3 : compare2 k (key n1) @$\equiv$@ EQ @$\rightarrow$@ getRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} {Set Level.zero} ( record { root = Just ( record { + lemma3 : compare2 k (key n1) !$\equiv$! EQ !$\rightarrow$! getRedBlackTree {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} {Set Level.zero} ( record { root = Just ( record { key = key n1 ; value = x ; right = right n1 ; left = left n1 ; color = Black - } ) ; nodeStack = s ; compare = @$\lambda$@ x@$\_{1}$@ y @$\rightarrow$@ compare2 x@$\_{1}$@ y } ) k ( \ t x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True) + } ) ; nodeStack = s ; compare = !$\lambda$! x!$\_{1}$! y !$\rightarrow$! compare2 x!$\_{1}$! y } ) k ( \ t x1 !$\rightarrow$! check2 x1 x !$\equiv$! True) lemma3 eq with compare2 x x | putTest1Lemma2 x ... | EQ | refl with compare2 k (key n1) | eq ... | EQ | refl with compare2 x x | putTest1Lemma2 x @@ -187,10 +187,10 @@ ... | Nothing = lemma1 where - lemma1 : getRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} {Set Level.zero} ( record { root = Just ( record { + lemma1 : getRedBlackTree {_} {_} {!$\mathbb{N}$!} {!$\mathbb{N}$!} {Set Level.zero} ( record { root = Just ( record { key = k ; value = x ; right = Nothing ; left = Nothing ; color = Red - } ) ; nodeStack = record { top = Nothing } ; compare = @$\lambda$@ x@$\_{1}$@ y @$\rightarrow$@ compare2 x@$\_{1}$@ y } ) k - ( \ t x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True) + } ) ; nodeStack = record { top = Nothing } ; compare = !$\lambda$! x!$\_{1}$! y !$\rightarrow$! compare2 x!$\_{1}$! y } ) k + ( \ t x1 !$\rightarrow$! check2 x1 x !$\equiv$! True) lemma1 with compare2 k k | putTest1Lemma2 k ... | EQ | refl with compare2 x x | putTest1Lemma2 x ... | EQ | refl = refl diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/sound-conv.agda.replaced --- a/Paper/src/sound-conv.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/sound-conv.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -whileConvPSemSound : {l : Level} @$\rightarrow$@ (input : Envc) @$\rightarrow$@ ((vari input @$\equiv$@ 0) @$\wedge$@ (varn input @$\equiv$@ c)) implies (varn input + vari input @$\equiv$@ c10 input) -whileConvPSemSound input = proof @$\lambda$@ x @$\rightarrow$@ (conversion input x) where - conversion : (env : Envc ) @$\rightarrow$@ (vari env @$\equiv$@ 0) @$\wedge$@ (varn env @$\equiv$@ c10 env) @$\rightarrow$@ varn env + vari env @$\equiv$@ c10 env +whileConvPSemSound : {l : Level} !$\rightarrow$! (input : Envc) !$\rightarrow$! ((vari input !$\equiv$! 0) !$\wedge$! (varn input !$\equiv$! c)) implies (varn input + vari input !$\equiv$! c10 input) +whileConvPSemSound input = proof !$\lambda$! x !$\rightarrow$! (conversion input x) where + conversion : (env : Envc ) !$\rightarrow$! (vari env !$\equiv$! 0) !$\wedge$! (varn env !$\equiv$! c10 env) !$\rightarrow$! varn env + vari env !$\equiv$! c10 env conversion e record { pi1 = refl ; pi2 = refl } = +zero diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/sound-impl.agda.replaced --- a/Paper/src/sound-impl.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/sound-impl.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,2 +1,2 @@ data _implies_ (A B : Set ) : Set (succ Zero) where - proof : ( A @$\rightarrow$@ B ) @$\rightarrow$@ A implies B + proof : ( A !$\rightarrow$! B ) !$\rightarrow$! A implies B diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/sound-loop.agda.replaced --- a/Paper/src/sound-loop.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/sound-loop.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -loopPPSem : (input output : Envc ) @$\rightarrow$@ output @$\equiv$@ loopPP (varn input) input refl - @$\rightarrow$@ (varn input + vari input @$\equiv$@ c10 input ) - @$\rightarrow$@ (varn input + vari input @$\equiv$@ c10 input ) implies (vari output @$\equiv$@ c10 output) +loopPPSem : (input output : Envc ) !$\rightarrow$! output !$\equiv$! loopPP (varn input) input refl + !$\rightarrow$! (varn input + vari input !$\equiv$! c10 input ) + !$\rightarrow$! (varn input + vari input !$\equiv$! c10 input ) implies (vari output !$\equiv$! c10 output) loopPPSem input output refl s2p = loopPPSemInduct (varn input) input refl refl s2p diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/sound-looppsem.agda.replaced --- a/Paper/src/sound-looppsem.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/sound-looppsem.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,5 +1,5 @@ -whileLoopPSemSound : {l : Level} @$\rightarrow$@ (input output : Envc ) - @$\rightarrow$@ (varn input + vari input @$\equiv$@ c10 input) - @$\rightarrow$@ output @$\equiv$@ loopPP (varn input) input refl - @$\rightarrow$@ (varn input + vari input @$\equiv$@ c10 input) implies (vari output @$\equiv$@ c10 output) +whileLoopPSemSound : {l : Level} !$\rightarrow$! (input output : Envc ) + !$\rightarrow$! (varn input + vari input !$\equiv$! c10 input) + !$\rightarrow$! output !$\equiv$! loopPP (varn input) input refl + !$\rightarrow$! (varn input + vari input !$\equiv$! c10 input) implies (vari output !$\equiv$! c10 output) whileLoopPSemSound {l} input output pre eq = loopPPSem input output eq pre diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/sound-pcom.agda.replaced --- a/Paper/src/sound-pcom.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/sound-pcom.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ -whileTestPSem : (c : @$\mathbb{N}$@) @$\rightarrow$@ whileTestP c - ( @$\lambda$@ env @$\rightarrow$@ @$\top$@ implies (vari env @$\equiv$@ 0) @$\wedge$@ (varn env @$\equiv$@ c10 env) ) -whileTestPSem c = proof ( @$\lambda$@ _ @$\rightarrow$@ record { pi1 = refl ; pi2 = refl } ) +whileTestPSem : (c : !$\mathbb{N}$!) !$\rightarrow$! whileTestP c + ( !$\lambda$! env !$\rightarrow$! !$\top$! implies (vari env !$\equiv$! 0) !$\wedge$! (varn env !$\equiv$! c10 env) ) +whileTestPSem c = proof ( !$\lambda$! _ !$\rightarrow$! record { pi1 = refl ; pi2 = refl } ) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/sound-psemcom.agda.replaced --- a/Paper/src/sound-psemcom.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/sound-psemcom.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -whileTestPSemSound : (c : @$\mathbb{N}$@ ) (output : Envc ) @$\rightarrow$@ - output @$\equiv$@ whileTestP c (@$\lambda$@ e @$\rightarrow$@ e) - @$\rightarrow$@ @$\top$@ implies ((vari output @$\equiv$@ 0) @$\wedge$@ (varn output @$\equiv$@ c)) +whileTestPSemSound : (c : !$\mathbb{N}$! ) (output : Envc ) !$\rightarrow$! + output !$\equiv$! whileTestP c (!$\lambda$! e !$\rightarrow$! e) + !$\rightarrow$! !$\top$! implies ((vari output !$\equiv$! 0) !$\wedge$! (varn output !$\equiv$! c)) whileTestPSemSound c output refl = whileTestPSem c diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/stack-product.agda.replaced --- a/Paper/src/stack-product.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/stack-product.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -15,23 +15,23 @@ data Maybe (a : Set) : Set where Nothing : Maybe a - Just : a @$\rightarrow$@ Maybe a + Just : a !$\rightarrow$! Maybe a record Stack {a t : Set} (stackImpl : Set) : Set where field stack : stackImpl - push : CodeSegment (stackImpl @$\times$@ a @$\times$@ (CodeSegment stackImpl t)) t - pop : CodeSegment (stackImpl @$\times$@ (CodeSegment (stackImpl @$\times$@ Maybe a) t)) t + push : CodeSegment (stackImpl !$\times$! a !$\times$! (CodeSegment stackImpl t)) t + pop : CodeSegment (stackImpl !$\times$! (CodeSegment (stackImpl !$\times$! Maybe a) t)) t data Element (a : Set) : Set where - cons : a @$\rightarrow$@ Maybe (Element a) @$\rightarrow$@ Element a + cons : a !$\rightarrow$! Maybe (Element a) !$\rightarrow$! Element a -datum : {a : Set} @$\rightarrow$@ Element a @$\rightarrow$@ a +datum : {a : Set} !$\rightarrow$! Element a !$\rightarrow$! a datum (cons a _) = a -next : {a : Set} @$\rightarrow$@ Element a @$\rightarrow$@ Maybe (Element a) +next : {a : Set} !$\rightarrow$! Element a !$\rightarrow$! Maybe (Element a) next (cons _ n) = n record SingleLinkedStack (a : Set) : Set where @@ -39,25 +39,25 @@ top : Maybe (Element a) open SingleLinkedStack -emptySingleLinkedStack : {a : Set} @$\rightarrow$@ SingleLinkedStack a +emptySingleLinkedStack : {a : Set} !$\rightarrow$! SingleLinkedStack a emptySingleLinkedStack = record {top = Nothing} -pushSingleLinkedStack : {a t : Set} @$\rightarrow$@ CodeSegment ((SingleLinkedStack a) @$\times$@ a @$\times$@ (CodeSegment (SingleLinkedStack a) t)) t +pushSingleLinkedStack : {a t : Set} !$\rightarrow$! CodeSegment ((SingleLinkedStack a) !$\times$! a !$\times$! (CodeSegment (SingleLinkedStack a) t)) t pushSingleLinkedStack = cs push where - push : {a t : Set} @$\rightarrow$@ ((SingleLinkedStack a) @$\times$@ a @$\times$@ (CodeSegment (SingleLinkedStack a) t)) @$\rightarrow$@ t + push : {a t : Set} !$\rightarrow$! ((SingleLinkedStack a) !$\times$! a !$\times$! (CodeSegment (SingleLinkedStack a) t)) !$\rightarrow$! t push (stack , datum , next) = goto next stack1 where element = cons datum (top stack) stack1 = record {top = Just element} -popSingleLinkedStack : {a t : Set} @$\rightarrow$@ CodeSegment (SingleLinkedStack a @$\times$@ (CodeSegment (SingleLinkedStack a @$\times$@ Maybe a) t)) t +popSingleLinkedStack : {a t : Set} !$\rightarrow$! CodeSegment (SingleLinkedStack a !$\times$! (CodeSegment (SingleLinkedStack a !$\times$! Maybe a) t)) t popSingleLinkedStack = cs pop where - pop : {a t : Set} @$\rightarrow$@ (SingleLinkedStack a @$\times$@ (CodeSegment (SingleLinkedStack a @$\times$@ Maybe a) t)) @$\rightarrow$@ t + pop : {a t : Set} !$\rightarrow$! (SingleLinkedStack a !$\times$! (CodeSegment (SingleLinkedStack a !$\times$! Maybe a) t)) !$\rightarrow$! t pop (record { top = Nothing } , nextCS) = goto nextCS (emptySingleLinkedStack , Nothing) pop (record { top = Just x } , nextCS) = goto nextCS (stack1 , (Just datum1)) where @@ -68,7 +68,7 @@ -createSingleLinkedStack : {a b : Set} @$\rightarrow$@ Stack {a} {b} (SingleLinkedStack a) +createSingleLinkedStack : {a b : Set} !$\rightarrow$! Stack {a} {b} (SingleLinkedStack a) createSingleLinkedStack = record { stack = emptySingleLinkedStack ; push = pushSingleLinkedStack ; pop = popSingleLinkedStack @@ -77,82 +77,82 @@ -test01 : {a : Set} @$\rightarrow$@ CodeSegment (SingleLinkedStack a @$\times$@ Maybe a) Bool -test01 = cs test01' +test01 : {a : Set} !$\rightarrow$! CodeSegment (SingleLinkedStack a !$\times$! Maybe a) Bool +test01 = cs test01!$\prime$! where - test01' : {a : Set} @$\rightarrow$@ (SingleLinkedStack a @$\times$@ Maybe a) @$\rightarrow$@ Bool - test01' (record { top = Nothing } , _) = False - test01' (record { top = Just x } , _) = True + test01!$\prime$! : {a : Set} !$\rightarrow$! (SingleLinkedStack a !$\times$! Maybe a) !$\rightarrow$! Bool + test01!$\prime$! (record { top = Nothing } , _) = False + test01!$\prime$! (record { top = Just x } , _) = True -test02 : {a : Set} @$\rightarrow$@ CodeSegment (SingleLinkedStack a) (SingleLinkedStack a @$\times$@ Maybe a) -test02 = cs test02' +test02 : {a : Set} !$\rightarrow$! CodeSegment (SingleLinkedStack a) (SingleLinkedStack a !$\times$! Maybe a) +test02 = cs test02!$\prime$! where - test02' : {a : Set} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (SingleLinkedStack a @$\times$@ Maybe a) - test02' stack = goto popSingleLinkedStack (stack , (cs id)) + test02!$\prime$! : {a : Set} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (SingleLinkedStack a !$\times$! Maybe a) + test02!$\prime$! stack = goto popSingleLinkedStack (stack , (cs id)) -test03 : {a : Set} @$\rightarrow$@ CodeSegment a (SingleLinkedStack a) -test03 = cs test03' +test03 : {a : Set} !$\rightarrow$! CodeSegment a (SingleLinkedStack a) +test03 = cs test03!$\prime$! where - test03' : {a : Set} @$\rightarrow$@ a @$\rightarrow$@ SingleLinkedStack a - test03' a = goto pushSingleLinkedStack (emptySingleLinkedStack , a , (cs id)) + test03!$\prime$! : {a : Set} !$\rightarrow$! a !$\rightarrow$! SingleLinkedStack a + test03!$\prime$! a = goto pushSingleLinkedStack (emptySingleLinkedStack , a , (cs id)) -lemma : {A : Set} {a : A} @$\rightarrow$@ goto (test03 ◎ test02 ◎ test01) a @$\equiv$@ False +lemma : {A : Set} {a : A} !$\rightarrow$! goto (test03 ◎ test02 ◎ test01) a !$\equiv$! False lemma = refl -n-push : {A : Set} {a : A} @$\rightarrow$@ CodeSegment (@$\mathbb{N}$@ @$\times$@ SingleLinkedStack A) (@$\mathbb{N}$@ @$\times$@ SingleLinkedStack A) +n-push : {A : Set} {a : A} !$\rightarrow$! CodeSegment (!$\mathbb{N}$! !$\times$! SingleLinkedStack A) (!$\mathbb{N}$! !$\times$! SingleLinkedStack A) n-push {A} {a} = cs (push {A} {a}) where - push : {A : Set} {a : A} @$\rightarrow$@ (@$\mathbb{N}$@ @$\times$@ SingleLinkedStack A) @$\rightarrow$@ (@$\mathbb{N}$@ @$\times$@ SingleLinkedStack A) + push : {A : Set} {a : A} !$\rightarrow$! (!$\mathbb{N}$! !$\times$! SingleLinkedStack A) !$\rightarrow$! (!$\mathbb{N}$! !$\times$! SingleLinkedStack A) push {A} {a} (zero , s) = (zero , s) push {A} {a} (suc n , s) = goto pushSingleLinkedStack (s , a , {!!} {- n-push -}) -- needs subtype {- -n-push : {A : Set} {a : A} @$\rightarrow$@ Nat @$\rightarrow$@ SingleLinkedStack A @$\rightarrow$@ SingleLinkedStack A +n-push : {A : Set} {a : A} !$\rightarrow$! Nat !$\rightarrow$! SingleLinkedStack A !$\rightarrow$! SingleLinkedStack A n-push zero s = s -n-push {A} {a} (suc n) s = pushSingleLinkedStack (n-push {A} {a} n s) a (\s @$\rightarrow$@ s) +n-push {A} {a} (suc n) s = pushSingleLinkedStack (n-push {A} {a} n s) a (\s !$\rightarrow$! s) -n-pop : {A : Set} {a : A} @$\rightarrow$@ Nat @$\rightarrow$@ SingleLinkedStack A @$\rightarrow$@ SingleLinkedStack A +n-pop : {A : Set} {a : A} !$\rightarrow$! Nat !$\rightarrow$! SingleLinkedStack A !$\rightarrow$! SingleLinkedStack A n-pop zero s = s -n-pop {A} {a} (suc n) s = popSingleLinkedStack (n-pop {A} {a} n s) (\s _ @$\rightarrow$@ s) +n-pop {A} {a} (suc n) s = popSingleLinkedStack (n-pop {A} {a} n s) (\s _ !$\rightarrow$! s) -open @$\equiv$@-Reasoning +open !$\equiv$!-Reasoning -push-pop-equiv : {A : Set} {a : A} (s : SingleLinkedStack A) @$\rightarrow$@ popSingleLinkedStack (pushSingleLinkedStack s a (\s @$\rightarrow$@ s)) (\s _ @$\rightarrow$@ s) @$\equiv$@ s +push-pop-equiv : {A : Set} {a : A} (s : SingleLinkedStack A) !$\rightarrow$! popSingleLinkedStack (pushSingleLinkedStack s a (\s !$\rightarrow$! s)) (\s _ !$\rightarrow$! s) !$\equiv$! s push-pop-equiv s = refl -push-and-n-pop : {A : Set} {a : A} (n : Nat) (s : SingleLinkedStack A) @$\rightarrow$@ n-pop {A} {a} (suc n) (pushSingleLinkedStack s a id) @$\equiv$@ n-pop {A} {a} n s +push-and-n-pop : {A : Set} {a : A} (n : Nat) (s : SingleLinkedStack A) !$\rightarrow$! n-pop {A} {a} (suc n) (pushSingleLinkedStack s a id) !$\equiv$! n-pop {A} {a} n s push-and-n-pop zero s = refl push-and-n-pop {A} {a} (suc n) s = begin n-pop (suc (suc n)) (pushSingleLinkedStack s a id) - @$\equiv$@@$\langle$@ refl @$\rangle$@ - popSingleLinkedStack (n-pop (suc n) (pushSingleLinkedStack s a id)) (\s _ @$\rightarrow$@ s) - @$\equiv$@@$\langle$@ cong (\s @$\rightarrow$@ popSingleLinkedStack s (\s _ @$\rightarrow$@ s)) (push-and-n-pop n s) @$\rangle$@ - popSingleLinkedStack (n-pop n s) (\s _ @$\rightarrow$@ s) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! + popSingleLinkedStack (n-pop (suc n) (pushSingleLinkedStack s a id)) (\s _ !$\rightarrow$! s) + !$\equiv$!!$\langle$! cong (\s !$\rightarrow$! popSingleLinkedStack s (\s _ !$\rightarrow$! s)) (push-and-n-pop n s) !$\rangle$! + popSingleLinkedStack (n-pop n s) (\s _ !$\rightarrow$! s) + !$\equiv$!!$\langle$! refl !$\rangle$! n-pop (suc n) s - @$\blacksquare$@ + !$\blacksquare$! -n-push-pop-equiv : {A : Set} {a : A} (n : Nat) (s : SingleLinkedStack A) @$\rightarrow$@ (n-pop {A} {a} n (n-push {A} {a} n s)) @$\equiv$@ s +n-push-pop-equiv : {A : Set} {a : A} (n : Nat) (s : SingleLinkedStack A) !$\rightarrow$! (n-pop {A} {a} n (n-push {A} {a} n s)) !$\equiv$! s n-push-pop-equiv zero s = refl n-push-pop-equiv {A} {a} (suc n) s = begin n-pop (suc n) (n-push (suc n) s) - @$\equiv$@@$\langle$@ refl @$\rangle$@ - n-pop (suc n) (pushSingleLinkedStack (n-push n s) a (\s @$\rightarrow$@ s)) - @$\equiv$@@$\langle$@ push-and-n-pop n (n-push n s) @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! + n-pop (suc n) (pushSingleLinkedStack (n-push n s) a (\s !$\rightarrow$! s)) + !$\equiv$!!$\langle$! push-and-n-pop n (n-push n s) !$\rangle$! n-pop n (n-push n s) - @$\equiv$@@$\langle$@ n-push-pop-equiv n s @$\rangle$@ + !$\equiv$!!$\langle$! n-push-pop-equiv n s !$\rangle$! s - @$\blacksquare$@ + !$\blacksquare$! -n-push-pop-equiv-empty : {A : Set} {a : A} @$\rightarrow$@ (n : Nat) @$\rightarrow$@ n-pop {A} {a} n (n-push {A} {a} n emptySingleLinkedStack) @$\equiv$@ emptySingleLinkedStack +n-push-pop-equiv-empty : {A : Set} {a : A} !$\rightarrow$! (n : Nat) !$\rightarrow$! n-pop {A} {a} n (n-push {A} {a} n emptySingleLinkedStack) !$\equiv$! emptySingleLinkedStack n-push-pop-equiv-empty n = n-push-pop-equiv n emptySingleLinkedStack -} diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/stack-subtype-sample.agda.replaced --- a/Paper/src/stack-subtype-sample.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/stack-subtype-sample.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -6,25 +6,25 @@ open import Data.Maybe open import Relation.Binary.PropositionalEquality -open import stack-subtype @$\mathbb{N}$@ +open import stack-subtype !$\mathbb{N}$! open import subtype Context as N open import subtype Meta as M record Num : Set where field - num : @$\mathbb{N}$@ + num : !$\mathbb{N}$! instance NumIsNormalDataSegment : N.DataSegment Num - NumIsNormalDataSegment = record { get = (\c @$\rightarrow$@ record { num = Context.n c}) - ; set = (\c n @$\rightarrow$@ record c {n = Num.num n})} + NumIsNormalDataSegment = record { get = (\c !$\rightarrow$! record { num = Context.n c}) + ; set = (\c n !$\rightarrow$! record c {n = Num.num n})} NumIsMetaDataSegment : M.DataSegment Num - NumIsMetaDataSegment = record { get = (\m @$\rightarrow$@ record {num = Context.n (Meta.context m)}) - ; set = (\m n @$\rightarrow$@ record m {context = record (Meta.context m) {n = Num.num n}})} + NumIsMetaDataSegment = record { get = (\m !$\rightarrow$! record {num = Context.n (Meta.context m)}) + ; set = (\m n !$\rightarrow$! record m {context = record (Meta.context m) {n = Num.num n}})} -plus3 : Num @$\rightarrow$@ Num +plus3 : Num !$\rightarrow$! Num plus3 record { num = n } = record {num = n + 3} plus3CS : N.CodeSegment Num Num @@ -33,42 +33,42 @@ plus5AndPushWithPlus3 : {mc : Meta} {{_ : N.DataSegment Num}} - @$\rightarrow$@ M.CodeSegment Num (Meta) -plus5AndPushWithPlus3 {mc} {{nn}} = M.cs (\n @$\rightarrow$@ record {context = con n ; nextCS = (liftContext {{nn}} {{nn}} plus3CS) ; stack = st} ) + !$\rightarrow$! M.CodeSegment Num (Meta) +plus5AndPushWithPlus3 {mc} {{nn}} = M.cs (\n !$\rightarrow$! record {context = con n ; nextCS = (liftContext {{nn}} {{nn}} plus3CS) ; stack = st} ) where co = Meta.context mc - con : Num @$\rightarrow$@ Context + con : Num !$\rightarrow$! Context con record { num = num } = N.DataSegment.set nn co record {num = num + 5} st = Meta.stack mc -push-sample : {{_ : N.DataSegment Num}} {{_ : M.DataSegment Num}} @$\rightarrow$@ Meta +push-sample : {{_ : N.DataSegment Num}} {{_ : M.DataSegment Num}} !$\rightarrow$! Meta push-sample {{nd}} {{md}} = M.exec {{md}} (plus5AndPushWithPlus3 {mc} {{nd}}) mc where con = record { n = 4 ; element = just 0} - code = N.cs (\c @$\rightarrow$@ c) + code = N.cs (\c !$\rightarrow$! c) mc = record {context = con ; stack = emptySingleLinkedStack ; nextCS = code} -push-sample-equiv : push-sample @$\equiv$@ record { nextCS = liftContext plus3CS +push-sample-equiv : push-sample !$\equiv$! record { nextCS = liftContext plus3CS ; stack = record { top = nothing} ; context = record { n = 9} } push-sample-equiv = refl -pushed-sample : {m : Meta} {{_ : N.DataSegment Num}} {{_ : M.DataSegment Num}} @$\rightarrow$@ Meta +pushed-sample : {m : Meta} {{_ : N.DataSegment Num}} {{_ : M.DataSegment Num}} !$\rightarrow$! Meta pushed-sample {m} {{nd}} {{md}} = M.exec {{md}} (M.csComp {m} {{md}} pushSingleLinkedStackCS (plus5AndPushWithPlus3 {mc} {{nd}})) mc where con = record { n = 4 ; element = just 0} - code = N.cs (\c @$\rightarrow$@ c) + code = N.cs (\c !$\rightarrow$! c) mc = record {context = con ; stack = emptySingleLinkedStack ; nextCS = code} -pushed-sample-equiv : {m : Meta} @$\rightarrow$@ - pushed-sample {m} @$\equiv$@ record { nextCS = liftContext plus3CS +pushed-sample-equiv : {m : Meta} !$\rightarrow$! + pushed-sample {m} !$\equiv$! record { nextCS = liftContext plus3CS ; stack = record { top = just (cons 0 nothing) } ; context = record { n = 12} } pushed-sample-equiv = refl @@ -78,27 +78,27 @@ pushNum : N.CodeSegment Context Context pushNum = N.cs pn where - pn : Context @$\rightarrow$@ Context + pn : Context !$\rightarrow$! Context pn record { n = n } = record { n = pred n ; element = just n} -pushOnce : Meta @$\rightarrow$@ Meta +pushOnce : Meta !$\rightarrow$! Meta pushOnce m = M.exec pushSingleLinkedStackCS m -n-push : {m : Meta} {{_ : M.DataSegment Meta}} (n : @$\mathbb{N}$@) @$\rightarrow$@ M.CodeSegment Meta Meta +n-push : {m : Meta} {{_ : M.DataSegment Meta}} (n : !$\mathbb{N}$!) !$\rightarrow$! M.CodeSegment Meta Meta n-push {{mm}} (zero) = M.cs {{mm}} {{mm}} id -n-push {m} {{mm}} (suc n) = M.cs {{mm}} {{mm}} (\m @$\rightarrow$@ M.exec {{mm}} {{mm}} (n-push {m} {{mm}} n) (pushOnce m)) +n-push {m} {{mm}} (suc n) = M.cs {{mm}} {{mm}} (\m !$\rightarrow$! M.exec {{mm}} {{mm}} (n-push {m} {{mm}} n) (pushOnce m)) -popOnce : Meta @$\rightarrow$@ Meta +popOnce : Meta !$\rightarrow$! Meta popOnce m = M.exec popSingleLinkedStackCS m -n-pop : {m : Meta} {{_ : M.DataSegment Meta}} (n : @$\mathbb{N}$@) @$\rightarrow$@ M.CodeSegment Meta Meta +n-pop : {m : Meta} {{_ : M.DataSegment Meta}} (n : !$\mathbb{N}$!) !$\rightarrow$! M.CodeSegment Meta Meta n-pop {{mm}} (zero) = M.cs {{mm}} {{mm}} id -n-pop {m} {{mm}} (suc n) = M.cs {{mm}} {{mm}} (\m @$\rightarrow$@ M.exec {{mm}} {{mm}} (n-pop {m} {{mm}} n) (popOnce m)) +n-pop {m} {{mm}} (suc n) = M.cs {{mm}} {{mm}} (\m !$\rightarrow$! M.exec {{mm}} {{mm}} (n-pop {m} {{mm}} n) (popOnce m)) -initMeta : @$\mathbb{N}$@ @$\rightarrow$@ Maybe @$\mathbb{N}$@ @$\rightarrow$@ N.CodeSegment Context Context @$\rightarrow$@ Meta +initMeta : !$\mathbb{N}$! !$\rightarrow$! Maybe !$\mathbb{N}$! !$\rightarrow$! N.CodeSegment Context Context !$\rightarrow$! Meta initMeta n mn code = record { context = record { n = n ; element = mn} ; stack = emptySingleLinkedStack ; nextCS = code @@ -109,7 +109,7 @@ meta = (initMeta 5 (just 9) pushNum) -n-push-cs-exec-equiv : n-push-cs-exec @$\equiv$@ record { nextCS = pushNum +n-push-cs-exec-equiv : n-push-cs-exec !$\equiv$! record { nextCS = pushNum ; context = record {n = 2 ; element = just 3} ; stack = record {top = just (cons 4 (just (cons 5 (just (cons 9 nothing)))))}} n-push-cs-exec-equiv = refl @@ -122,7 +122,7 @@ ; stack = record {top = just (cons 9 (just (cons 8 (just (cons 7 (just (cons 6 (just (cons 5 nothing)))))))))} } -n-pop-cs-exec-equiv : n-pop-cs-exec @$\equiv$@ record { nextCS = N.cs id +n-pop-cs-exec-equiv : n-pop-cs-exec !$\equiv$! record { nextCS = N.cs id ; context = record { n = 0 ; element = just 6} ; stack = record { top = just (cons 5 nothing)} } @@ -130,83 +130,83 @@ n-pop-cs-exec-equiv = refl -open @$\equiv$@-Reasoning +open !$\equiv$!-Reasoning -id-meta : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ SingleLinkedStack @$\mathbb{N}$@ @$\rightarrow$@ Meta +id-meta : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! SingleLinkedStack !$\mathbb{N}$! !$\rightarrow$! Meta id-meta n e s = record { context = record {n = n ; element = just e} ; nextCS = (N.cs id) ; stack = s} -exec-comp : (f g : M.CodeSegment Meta Meta) (m : Meta) @$\rightarrow$@ M.exec (M.csComp {m} f g) m @$\equiv$@ M.exec f (M.exec g m) +exec-comp : (f g : M.CodeSegment Meta Meta) (m : Meta) !$\rightarrow$! M.exec (M.csComp {m} f g) m !$\equiv$! M.exec f (M.exec g m) exec-comp (M.cs x) (M.cs _) m = refl -push-pop-type : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Element @$\mathbb{N}$@ @$\rightarrow$@ Set@$\_{1}$@ -push-pop-type n e x s = M.exec (M.csComp {meta} (M.cs popOnce) (M.cs pushOnce)) meta @$\equiv$@ meta +push-pop-type : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! Element !$\mathbb{N}$! !$\rightarrow$! Set!$\_{1}$! +push-pop-type n e x s = M.exec (M.csComp {meta} (M.cs popOnce) (M.cs pushOnce)) meta !$\equiv$! meta where meta = id-meta n e record {top = just (cons x (just s))} -push-pop : (n e x : @$\mathbb{N}$@) @$\rightarrow$@ (s : Element @$\mathbb{N}$@) @$\rightarrow$@ push-pop-type n e x s +push-pop : (n e x : !$\mathbb{N}$!) !$\rightarrow$! (s : Element !$\mathbb{N}$!) !$\rightarrow$! push-pop-type n e x s push-pop n e x s = refl -pop-n-push-type : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ SingleLinkedStack @$\mathbb{N}$@ @$\rightarrow$@ Set@$\_{1}$@ +pop-n-push-type : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! SingleLinkedStack !$\mathbb{N}$! !$\rightarrow$! Set!$\_{1}$! pop-n-push-type n cn ce s = M.exec (M.csComp {meta} (M.cs popOnce) (n-push {meta} (suc n))) meta - @$\equiv$@ M.exec (n-push {meta} n) meta + !$\equiv$! M.exec (n-push {meta} n) meta where meta = id-meta cn ce s -pop-n-push : (n cn ce : @$\mathbb{N}$@) @$\rightarrow$@ (s : SingleLinkedStack @$\mathbb{N}$@) @$\rightarrow$@ pop-n-push-type n cn ce s +pop-n-push : (n cn ce : !$\mathbb{N}$!) !$\rightarrow$! (s : SingleLinkedStack !$\mathbb{N}$!) !$\rightarrow$! pop-n-push-type n cn ce s pop-n-push zero cn ce s = refl pop-n-push (suc n) cn ce s = begin M.exec (M.csComp {id-meta cn ce s} (M.cs popOnce) (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc (suc n)))) (id-meta cn ce s) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (M.csComp {id-meta cn ce s} (M.cs popOnce) (M.csComp {id-meta cn ce s} (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc n)) (M.cs pushOnce))) (id-meta cn ce s) - @$\equiv$@@$\langle$@ exec-comp (M.cs popOnce) (M.csComp {id-meta cn ce s} (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc n)) (M.cs pushOnce)) (id-meta cn ce s) @$\rangle$@ + !$\equiv$!!$\langle$! exec-comp (M.cs popOnce) (M.csComp {id-meta cn ce s} (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc n)) (M.cs pushOnce)) (id-meta cn ce s) !$\rangle$! M.exec (M.cs popOnce) (M.exec (M.csComp {id-meta cn ce s} (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc n)) (M.cs pushOnce)) (id-meta cn ce s)) - @$\equiv$@@$\langle$@ cong (\x @$\rightarrow$@ M.exec (M.cs popOnce) x) (exec-comp (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc n)) (M.cs pushOnce) (id-meta cn ce s)) @$\rangle$@ + !$\equiv$!!$\langle$! cong (\x !$\rightarrow$! M.exec (M.cs popOnce) x) (exec-comp (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc n)) (M.cs pushOnce) (id-meta cn ce s)) !$\rangle$! M.exec (M.cs popOnce) (M.exec (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc n))(M.exec (M.cs pushOnce) (id-meta cn ce s))) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (M.cs popOnce) (M.exec (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc n)) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}))) - @$\equiv$@@$\langle$@ sym (exec-comp (M.cs popOnce) (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc n)) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}))) @$\rangle$@ + !$\equiv$!!$\langle$! sym (exec-comp (M.cs popOnce) (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc n)) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}))) !$\rangle$! M.exec (M.csComp {id-meta cn ce s} (M.cs popOnce) (n-push {id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})} (suc n))) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})) - @$\equiv$@@$\langle$@ pop-n-push n cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}) @$\rangle$@ + !$\equiv$!!$\langle$! pop-n-push n cn ce (record {top = just (cons ce (SingleLinkedStack.top s))}) !$\rangle$! M.exec (n-push n) (id-meta cn ce (record {top = just (cons ce (SingleLinkedStack.top s))})) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (n-push n) (pushOnce (id-meta cn ce s)) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (n-push n) (M.exec (M.cs pushOnce) (id-meta cn ce s)) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (n-push {id-meta cn ce s} (suc n)) (id-meta cn ce s) - @$\blacksquare$@ + !$\blacksquare$! -n-push-pop-type : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ SingleLinkedStack @$\mathbb{N}$@ @$\rightarrow$@ Set@$\_{1}$@ -n-push-pop-type n cn ce st = M.exec (M.csComp {meta} (n-pop {meta} n) (n-push {meta} n)) meta @$\equiv$@ meta +n-push-pop-type : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! SingleLinkedStack !$\mathbb{N}$! !$\rightarrow$! Set!$\_{1}$! +n-push-pop-type n cn ce st = M.exec (M.csComp {meta} (n-pop {meta} n) (n-push {meta} n)) meta !$\equiv$! meta where meta = id-meta cn ce st -n-push-pop : (n cn ce : @$\mathbb{N}$@) @$\rightarrow$@ (s : SingleLinkedStack @$\mathbb{N}$@) @$\rightarrow$@ n-push-pop-type n cn ce s +n-push-pop : (n cn ce : !$\mathbb{N}$!) !$\rightarrow$! (s : SingleLinkedStack !$\mathbb{N}$!) !$\rightarrow$! n-push-pop-type n cn ce s n-push-pop zero cn ce s = refl n-push-pop (suc n) cn ce s = begin M.exec (M.csComp {id-meta cn ce s} (n-pop {id-meta cn ce s} (suc n)) (n-push {id-meta cn ce s} (suc n))) (id-meta cn ce s) - @$\equiv$@@$\langle$@ refl @$\rangle$@ - M.exec (M.csComp {id-meta cn ce s} (M.cs (\m @$\rightarrow$@ M.exec (n-pop {id-meta cn ce s} n) (popOnce m))) (n-push {id-meta cn ce s} (suc n))) (id-meta cn ce s) - @$\equiv$@@$\langle$@ exec-comp (M.cs (\m @$\rightarrow$@ M.exec (n-pop n) (popOnce m))) (n-push {id-meta cn ce s} (suc n)) (id-meta cn ce s) @$\rangle$@ - M.exec (M.cs (\m @$\rightarrow$@ M.exec (n-pop {id-meta cn ce s} n) (popOnce m))) (M.exec (n-push {id-meta cn ce s} (suc n)) (id-meta cn ce s)) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! + M.exec (M.csComp {id-meta cn ce s} (M.cs (\m !$\rightarrow$! M.exec (n-pop {id-meta cn ce s} n) (popOnce m))) (n-push {id-meta cn ce s} (suc n))) (id-meta cn ce s) + !$\equiv$!!$\langle$! exec-comp (M.cs (\m !$\rightarrow$! M.exec (n-pop n) (popOnce m))) (n-push {id-meta cn ce s} (suc n)) (id-meta cn ce s) !$\rangle$! + M.exec (M.cs (\m !$\rightarrow$! M.exec (n-pop {id-meta cn ce s} n) (popOnce m))) (M.exec (n-push {id-meta cn ce s} (suc n)) (id-meta cn ce s)) + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (n-pop n) (popOnce (M.exec (n-push {id-meta cn ce s} (suc n)) (id-meta cn ce s))) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! M.exec (n-pop n) (M.exec (M.cs popOnce) (M.exec (n-push {id-meta cn ce s} (suc n)) (id-meta cn ce s))) - @$\equiv$@@$\langle$@ cong (\x @$\rightarrow$@ M.exec (n-pop {id-meta cn ce s} n) x) (sym (exec-comp (M.cs popOnce) (n-push {id-meta cn ce s} (suc n)) (id-meta cn ce s))) @$\rangle$@ + !$\equiv$!!$\langle$! cong (\x !$\rightarrow$! M.exec (n-pop {id-meta cn ce s} n) x) (sym (exec-comp (M.cs popOnce) (n-push {id-meta cn ce s} (suc n)) (id-meta cn ce s))) !$\rangle$! M.exec (n-pop n) (M.exec (M.csComp {id-meta cn ce s} (M.cs popOnce) (n-push {id-meta cn ce s} (suc n))) (id-meta cn ce s)) - @$\equiv$@@$\langle$@ cong (\x @$\rightarrow$@ M.exec (n-pop {id-meta cn ce s} n) x) (pop-n-push n cn ce s) @$\rangle$@ + !$\equiv$!!$\langle$! cong (\x !$\rightarrow$! M.exec (n-pop {id-meta cn ce s} n) x) (pop-n-push n cn ce s) !$\rangle$! M.exec (n-pop n) (M.exec (n-push n) (id-meta cn ce s)) - @$\equiv$@@$\langle$@ sym (exec-comp (n-pop n) (n-push n) (id-meta cn ce s)) @$\rangle$@ + !$\equiv$!!$\langle$! sym (exec-comp (n-pop n) (n-push n) (id-meta cn ce s)) !$\rangle$! M.exec (M.csComp (n-pop n) (n-push n)) (id-meta cn ce s) - @$\equiv$@@$\langle$@ n-push-pop n cn ce s @$\rangle$@ + !$\equiv$!!$\langle$! n-push-pop n cn ce s !$\rangle$! id-meta cn ce s - @$\blacksquare$@ + !$\blacksquare$! diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/stack-subtype.agda.replaced --- a/Paper/src/stack-subtype.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/stack-subtype.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -9,12 +9,12 @@ -- data definitions data Element (a : Set) : Set where - cons : a @$\rightarrow$@ Maybe (Element a) @$\rightarrow$@ Element a + cons : a !$\rightarrow$! Maybe (Element a) !$\rightarrow$! Element a -datum : {a : Set} @$\rightarrow$@ Element a @$\rightarrow$@ a +datum : {a : Set} !$\rightarrow$! Element a !$\rightarrow$! a datum (cons a _) = a -next : {a : Set} @$\rightarrow$@ Element a @$\rightarrow$@ Maybe (Element a) +next : {a : Set} !$\rightarrow$! Element a !$\rightarrow$! Maybe (Element a) next (cons _ n) = n record SingleLinkedStack (a : Set) : Set where @@ -25,7 +25,7 @@ record Context : Set where field -- fields for concrete data segments - n : @$\mathbb{N}$@ + n : !$\mathbb{N}$! -- fields for stack element : Maybe A @@ -37,10 +37,10 @@ instance ContextIsDataSegment : N.DataSegment Context - ContextIsDataSegment = record {get = (\c @$\rightarrow$@ c) ; set = (\_ c @$\rightarrow$@ c)} + ContextIsDataSegment = record {get = (\c !$\rightarrow$! c) ; set = (\_ c !$\rightarrow$! c)} -record Meta : Set@$\_{1}$@ where +record Meta : Set!$\_{1}$! where field -- context as set of data segments context : Context @@ -55,17 +55,17 @@ instance MetaIncludeContext : M.DataSegment Context MetaIncludeContext = record { get = Meta.context - ; set = (\m c @$\rightarrow$@ record m {context = c}) } + ; set = (\m c !$\rightarrow$! record m {context = c}) } MetaIsMetaDataSegment : M.DataSegment Meta - MetaIsMetaDataSegment = record { get = (\m @$\rightarrow$@ m) ; set = (\_ m @$\rightarrow$@ m) } + MetaIsMetaDataSegment = record { get = (\m !$\rightarrow$! m) ; set = (\_ m !$\rightarrow$! m) } -liftMeta : {X Y : Set} {{_ : M.DataSegment X}} {{_ : M.DataSegment Y}} @$\rightarrow$@ N.CodeSegment X Y @$\rightarrow$@ M.CodeSegment X Y +liftMeta : {X Y : Set} {{_ : M.DataSegment X}} {{_ : M.DataSegment Y}} !$\rightarrow$! N.CodeSegment X Y !$\rightarrow$! M.CodeSegment X Y liftMeta (N.cs f) = M.cs f -liftContext : {X Y : Set} {{_ : N.DataSegment X}} {{_ : N.DataSegment Y}} @$\rightarrow$@ N.CodeSegment X Y @$\rightarrow$@ N.CodeSegment Context Context -liftContext {{x}} {{y}} (N.cs f) = N.cs (\c @$\rightarrow$@ N.DataSegment.set y c (f (N.DataSegment.get x c))) +liftContext : {X Y : Set} {{_ : N.DataSegment X}} {{_ : N.DataSegment Y}} !$\rightarrow$! N.CodeSegment X Y !$\rightarrow$! N.CodeSegment Context Context +liftContext {{x}} {{y}} (N.cs f) = N.cs (\c !$\rightarrow$! N.DataSegment.set y c (f (N.DataSegment.get x c))) -- definition based from Gears(209:5708390a9d88) src/parallel_execution @@ -73,27 +73,27 @@ emptySingleLinkedStack = record {top = nothing} -pushSingleLinkedStack : Meta @$\rightarrow$@ Meta +pushSingleLinkedStack : Meta !$\rightarrow$! Meta pushSingleLinkedStack m = M.exec (liftMeta n) (record m {stack = (push s e) }) where n = Meta.nextCS m s = Meta.stack m e = Context.element (Meta.context m) - push : SingleLinkedStack A @$\rightarrow$@ Maybe A @$\rightarrow$@ SingleLinkedStack A + push : SingleLinkedStack A !$\rightarrow$! Maybe A !$\rightarrow$! SingleLinkedStack A push s nothing = s push s (just x) = record {top = just (cons x (top s))} -popSingleLinkedStack : Meta @$\rightarrow$@ Meta +popSingleLinkedStack : Meta !$\rightarrow$! Meta popSingleLinkedStack m = M.exec (liftMeta n) (record m {stack = (st m) ; context = record con {element = (elem m)}}) where n = Meta.nextCS m con = Meta.context m - elem : Meta @$\rightarrow$@ Maybe A + elem : Meta !$\rightarrow$! Maybe A elem record {stack = record { top = (just (cons x _)) }} = just x elem record {stack = record { top = nothing }} = nothing - st : Meta @$\rightarrow$@ SingleLinkedStack A + st : Meta !$\rightarrow$! SingleLinkedStack A st record {stack = record { top = (just (cons _ s)) }} = record {top = s} st record {stack = record { top = nothing }} = record {top = nothing} @@ -116,7 +116,7 @@ firstMeta : Meta firstMeta = record { context = firstContext ; stack = emptySingleLinkedStack - ; nextCS = (N.cs (\m @$\rightarrow$@ m)) + ; nextCS = (N.cs (\m !$\rightarrow$! m)) } diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/stack.agda.replaced --- a/Paper/src/stack.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/stack.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -5,60 +5,60 @@ open import Relation.Binary.Core open import Data.Nat -ex : 1 + 2 @$\equiv$@ 3 +ex : 1 + 2 !$\equiv$! 3 ex = refl data Bool {n : Level } : Set n where True : Bool False : Bool -record _@$\wedge$@_ {n : Level } (a : Set n) (b : Set n): Set n where +record _!$\wedge$!_ {n : Level } (a : Set n) (b : Set n): Set n where field pi1 : a pi2 : b data Maybe {n : Level } (a : Set n) : Set n where Nothing : Maybe a - Just : a @$\rightarrow$@ Maybe a + Just : a !$\rightarrow$! Maybe a -record StackMethods {n m : Level } (a : Set n ) {t : Set m }(stackImpl : Set n ) : Set (m Level.@$\sqcup$@ n) where +record StackMethods {n m : Level } (a : Set n ) {t : Set m }(stackImpl : Set n ) : Set (m Level.!$\sqcup$! n) where field - push : stackImpl @$\rightarrow$@ a @$\rightarrow$@ (stackImpl @$\rightarrow$@ t) @$\rightarrow$@ t - pop : stackImpl @$\rightarrow$@ (stackImpl @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - pop2 : stackImpl @$\rightarrow$@ (stackImpl @$\rightarrow$@ Maybe a @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - get : stackImpl @$\rightarrow$@ (stackImpl @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - get2 : stackImpl @$\rightarrow$@ (stackImpl @$\rightarrow$@ Maybe a @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - clear : stackImpl @$\rightarrow$@ (stackImpl @$\rightarrow$@ t) @$\rightarrow$@ t + push : stackImpl !$\rightarrow$! a !$\rightarrow$! (stackImpl !$\rightarrow$! t) !$\rightarrow$! t + pop : stackImpl !$\rightarrow$! (stackImpl !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + pop2 : stackImpl !$\rightarrow$! (stackImpl !$\rightarrow$! Maybe a !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + get : stackImpl !$\rightarrow$! (stackImpl !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + get2 : stackImpl !$\rightarrow$! (stackImpl !$\rightarrow$! Maybe a !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + clear : stackImpl !$\rightarrow$! (stackImpl !$\rightarrow$! t) !$\rightarrow$! t open StackMethods -record Stack {n m : Level } (a : Set n ) {t : Set m } (si : Set n ) : Set (m Level.@$\sqcup$@ n) where +record Stack {n m : Level } (a : Set n ) {t : Set m } (si : Set n ) : Set (m Level.!$\sqcup$! n) where field stack : si stackMethods : StackMethods {n} {m} a {t} si - pushStack : a @$\rightarrow$@ (Stack a si @$\rightarrow$@ t) @$\rightarrow$@ t - pushStack d next = push (stackMethods ) (stack ) d (\s1 @$\rightarrow$@ next (record {stack = s1 ; stackMethods = stackMethods } )) - popStack : (Stack a si @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - popStack next = pop (stackMethods ) (stack ) (\s1 d1 @$\rightarrow$@ next (record {stack = s1 ; stackMethods = stackMethods }) d1 ) - pop2Stack : (Stack a si @$\rightarrow$@ Maybe a @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - pop2Stack next = pop2 (stackMethods ) (stack ) (\s1 d1 d2 @$\rightarrow$@ next (record {stack = s1 ; stackMethods = stackMethods }) d1 d2) - getStack : (Stack a si @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - getStack next = get (stackMethods ) (stack ) (\s1 d1 @$\rightarrow$@ next (record {stack = s1 ; stackMethods = stackMethods }) d1 ) - get2Stack : (Stack a si @$\rightarrow$@ Maybe a @$\rightarrow$@ Maybe a @$\rightarrow$@ t) @$\rightarrow$@ t - get2Stack next = get2 (stackMethods ) (stack ) (\s1 d1 d2 @$\rightarrow$@ next (record {stack = s1 ; stackMethods = stackMethods }) d1 d2) - clearStack : (Stack a si @$\rightarrow$@ t) @$\rightarrow$@ t - clearStack next = clear (stackMethods ) (stack ) (\s1 @$\rightarrow$@ next (record {stack = s1 ; stackMethods = stackMethods } )) + pushStack : a !$\rightarrow$! (Stack a si !$\rightarrow$! t) !$\rightarrow$! t + pushStack d next = push (stackMethods ) (stack ) d (\s1 !$\rightarrow$! next (record {stack = s1 ; stackMethods = stackMethods } )) + popStack : (Stack a si !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + popStack next = pop (stackMethods ) (stack ) (\s1 d1 !$\rightarrow$! next (record {stack = s1 ; stackMethods = stackMethods }) d1 ) + pop2Stack : (Stack a si !$\rightarrow$! Maybe a !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + pop2Stack next = pop2 (stackMethods ) (stack ) (\s1 d1 d2 !$\rightarrow$! next (record {stack = s1 ; stackMethods = stackMethods }) d1 d2) + getStack : (Stack a si !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + getStack next = get (stackMethods ) (stack ) (\s1 d1 !$\rightarrow$! next (record {stack = s1 ; stackMethods = stackMethods }) d1 ) + get2Stack : (Stack a si !$\rightarrow$! Maybe a !$\rightarrow$! Maybe a !$\rightarrow$! t) !$\rightarrow$! t + get2Stack next = get2 (stackMethods ) (stack ) (\s1 d1 d2 !$\rightarrow$! next (record {stack = s1 ; stackMethods = stackMethods }) d1 d2) + clearStack : (Stack a si !$\rightarrow$! t) !$\rightarrow$! t + clearStack next = clear (stackMethods ) (stack ) (\s1 !$\rightarrow$! next (record {stack = s1 ; stackMethods = stackMethods } )) open Stack {-- data Element {n : Level } (a : Set n) : Set n where - cons : a @$\rightarrow$@ Maybe (Element a) @$\rightarrow$@ Element a + cons : a !$\rightarrow$! Maybe (Element a) !$\rightarrow$! Element a -datum : {n : Level } {a : Set n} @$\rightarrow$@ Element a @$\rightarrow$@ a +datum : {n : Level } {a : Set n} !$\rightarrow$! Element a !$\rightarrow$! a datum (cons a _) = a -next : {n : Level } {a : Set n} @$\rightarrow$@ Element a @$\rightarrow$@ Maybe (Element a) +next : {n : Level } {a : Set n} !$\rightarrow$! Element a !$\rightarrow$! Maybe (Element a) next (cons _ n) = n --} @@ -79,14 +79,14 @@ top : Maybe (Element a) open SingleLinkedStack -pushSingleLinkedStack : {n m : Level } {t : Set m } {Data : Set n} @$\rightarrow$@ SingleLinkedStack Data @$\rightarrow$@ Data @$\rightarrow$@ (Code : SingleLinkedStack Data @$\rightarrow$@ t) @$\rightarrow$@ t +pushSingleLinkedStack : {n m : Level } {t : Set m } {Data : Set n} !$\rightarrow$! SingleLinkedStack Data !$\rightarrow$! Data !$\rightarrow$! (Code : SingleLinkedStack Data !$\rightarrow$! t) !$\rightarrow$! t pushSingleLinkedStack stack datum next = next stack1 where element = cons datum (top stack) stack1 = record {top = Just element} -popSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t +popSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t popSingleLinkedStack stack cs with (top stack) ... | Nothing = cs stack Nothing ... | Just d = cs stack1 (Just data1) @@ -94,45 +94,45 @@ data1 = datum d stack1 = record { top = (next d) } -pop2SingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t +pop2SingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t pop2SingleLinkedStack {n} {m} {t} {a} stack cs with (top stack) ... | Nothing = cs stack Nothing Nothing -... | Just d = pop2SingleLinkedStack' {n} {m} stack cs +... | Just d = pop2SingleLinkedStack!$\prime$! {n} {m} stack cs where - pop2SingleLinkedStack' : {n m : Level } {t : Set m } @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t - pop2SingleLinkedStack' stack cs with (next d) + pop2SingleLinkedStack!$\prime$! : {n m : Level } {t : Set m } !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t + pop2SingleLinkedStack!$\prime$! stack cs with (next d) ... | Nothing = cs stack Nothing Nothing ... | Just d1 = cs (record {top = (next d1)}) (Just (datum d)) (Just (datum d1)) -getSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t +getSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t getSingleLinkedStack stack cs with (top stack) ... | Nothing = cs stack Nothing ... | Just d = cs stack (Just data1) where data1 = datum d -get2SingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t +get2SingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t get2SingleLinkedStack {n} {m} {t} {a} stack cs with (top stack) ... | Nothing = cs stack Nothing Nothing -... | Just d = get2SingleLinkedStack' {n} {m} stack cs +... | Just d = get2SingleLinkedStack!$\prime$! {n} {m} stack cs where - get2SingleLinkedStack' : {n m : Level} {t : Set m } @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (Code : SingleLinkedStack a @$\rightarrow$@ (Maybe a) @$\rightarrow$@ (Maybe a) @$\rightarrow$@ t) @$\rightarrow$@ t - get2SingleLinkedStack' stack cs with (next d) + get2SingleLinkedStack!$\prime$! : {n m : Level} {t : Set m } !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (Code : SingleLinkedStack a !$\rightarrow$! (Maybe a) !$\rightarrow$! (Maybe a) !$\rightarrow$! t) !$\rightarrow$! t + get2SingleLinkedStack!$\prime$! stack cs with (next d) ... | Nothing = cs stack Nothing Nothing ... | Just d1 = cs stack (Just (datum d)) (Just (datum d1)) -clearSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ (SingleLinkedStack a @$\rightarrow$@ t) @$\rightarrow$@ t +clearSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! (SingleLinkedStack a !$\rightarrow$! t) !$\rightarrow$! t clearSingleLinkedStack stack next = next (record {top = Nothing}) -emptySingleLinkedStack : {n : Level } {a : Set n} @$\rightarrow$@ SingleLinkedStack a +emptySingleLinkedStack : {n : Level } {a : Set n} !$\rightarrow$! SingleLinkedStack a emptySingleLinkedStack = record {top = Nothing} ----- -- Basic stack implementations are specifications of a Stack -- -singleLinkedStackSpec : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ StackMethods {n} {m} a {t} (SingleLinkedStack a) +singleLinkedStackSpec : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! StackMethods {n} {m} a {t} (SingleLinkedStack a) singleLinkedStackSpec = record { push = pushSingleLinkedStack ; pop = popSingleLinkedStack @@ -142,7 +142,7 @@ ; clear = clearSingleLinkedStack } -createSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ Stack {n} {m} a {t} (SingleLinkedStack a) +createSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! Stack {n} {m} a {t} (SingleLinkedStack a) createSingleLinkedStack = record { stack = emptySingleLinkedStack ; stackMethods = singleLinkedStackSpec diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/stackImpl.agda.replaced --- a/Paper/src/stackImpl.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/stackImpl.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -11,7 +11,7 @@ top : Maybe (Element a) open SingleLinkedStack -pushSingleLinkedStack : {n m : Level } {t : Set m } {Data : Set n} @$\rightarrow$@ SingleLinkedStack Data @$\rightarrow$@ Data @$\rightarrow$@ (Code : SingleLinkedStack Data @$\rightarrow$@ t) @$\rightarrow$@ t +pushSingleLinkedStack : {n m : Level } {t : Set m } {Data : Set n} !$\rightarrow$! SingleLinkedStack Data !$\rightarrow$! Data !$\rightarrow$! (Code : SingleLinkedStack Data !$\rightarrow$! t) !$\rightarrow$! t pushSingleLinkedStack stack datum next = next stack1 where element = cons datum (top stack) @@ -21,7 +21,7 @@ -- Basic stack implementations are specifications of a Stack -singleLinkedStackSpec : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ StackMethods {n} {m} a {t} (SingleLinkedStack a) +singleLinkedStackSpec : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! StackMethods {n} {m} a {t} (SingleLinkedStack a) singleLinkedStackSpec = record { push = pushSingleLinkedStack ; pop = popSingleLinkedStack @@ -31,7 +31,7 @@ ; clear = clearSingleLinkedStack } -createSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} @$\rightarrow$@ Stack {n} {m} a {t} (SingleLinkedStack a) +createSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} !$\rightarrow$! Stack {n} {m} a {t} (SingleLinkedStack a) createSingleLinkedStack = record { stack = emptySingleLinkedStack ; stackMethods = singleLinkedStackSpec diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/stackTest.agda.replaced --- a/Paper/src/stackTest.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/stackTest.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -17,65 +17,65 @@ -- proof of properties ( concrete cases ) -- -test01 : {n : Level } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ Maybe a @$\rightarrow$@ Bool {n} +test01 : {n : Level } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! Maybe a !$\rightarrow$! Bool {n} test01 stack _ with (top stack) ... | (Just _) = True ... | Nothing = False -test02 : {n : Level } {a : Set n} @$\rightarrow$@ SingleLinkedStack a @$\rightarrow$@ Bool +test02 : {n : Level } {a : Set n} !$\rightarrow$! SingleLinkedStack a !$\rightarrow$! Bool test02 stack = popSingleLinkedStack stack test01 -test03 : {n : Level } {a : Set n} @$\rightarrow$@ a @$\rightarrow$@ Bool +test03 : {n : Level } {a : Set n} !$\rightarrow$! a !$\rightarrow$! Bool test03 v = pushSingleLinkedStack emptySingleLinkedStack v test02 -- after a push and a pop, the stack is empty -lemma : {n : Level} {A : Set n} {a : A} @$\rightarrow$@ test03 a @$\equiv$@ False +lemma : {n : Level} {A : Set n} {a : A} !$\rightarrow$! test03 a !$\equiv$! False lemma = refl -testStack01 : {n m : Level } {a : Set n} @$\rightarrow$@ a @$\rightarrow$@ Bool {m} +testStack01 : {n m : Level } {a : Set n} !$\rightarrow$! a !$\rightarrow$! Bool {m} testStack01 v = pushStack createSingleLinkedStack v ( - \s @$\rightarrow$@ popStack s (\s1 d1 @$\rightarrow$@ True)) + \s !$\rightarrow$! popStack s (\s1 d1 !$\rightarrow$! True)) -- after push 1 and 2, pop2 get 1 and 2 -testStack02 : {m : Level } @$\rightarrow$@ ( Stack @$\mathbb{N}$@ (SingleLinkedStack @$\mathbb{N}$@) @$\rightarrow$@ Bool {m} ) @$\rightarrow$@ Bool {m} +testStack02 : {m : Level } !$\rightarrow$! ( Stack !$\mathbb{N}$! (SingleLinkedStack !$\mathbb{N}$!) !$\rightarrow$! Bool {m} ) !$\rightarrow$! Bool {m} testStack02 cs = pushStack createSingleLinkedStack 1 ( - \s @$\rightarrow$@ pushStack s 2 cs) + \s !$\rightarrow$! pushStack s 2 cs) -testStack031 : (d1 d2 : @$\mathbb{N}$@ ) @$\rightarrow$@ Bool {Zero} +testStack031 : (d1 d2 : !$\mathbb{N}$! ) !$\rightarrow$! Bool {Zero} testStack031 2 1 = True testStack031 _ _ = False -testStack032 : (d1 d2 : Maybe @$\mathbb{N}$@) @$\rightarrow$@ Bool {Zero} +testStack032 : (d1 d2 : Maybe !$\mathbb{N}$!) !$\rightarrow$! Bool {Zero} testStack032 (Just d1) (Just d2) = testStack031 d1 d2 testStack032 _ _ = False -testStack03 : {m : Level } @$\rightarrow$@ Stack @$\mathbb{N}$@ (SingleLinkedStack @$\mathbb{N}$@) @$\rightarrow$@ ((Maybe @$\mathbb{N}$@) @$\rightarrow$@ (Maybe @$\mathbb{N}$@) @$\rightarrow$@ Bool {m} ) @$\rightarrow$@ Bool {m} +testStack03 : {m : Level } !$\rightarrow$! Stack !$\mathbb{N}$! (SingleLinkedStack !$\mathbb{N}$!) !$\rightarrow$! ((Maybe !$\mathbb{N}$!) !$\rightarrow$! (Maybe !$\mathbb{N}$!) !$\rightarrow$! Bool {m} ) !$\rightarrow$! Bool {m} testStack03 s cs = pop2Stack s ( - \s d1 d2 @$\rightarrow$@ cs d1 d2 ) + \s d1 d2 !$\rightarrow$! cs d1 d2 ) testStack04 : Bool -testStack04 = testStack02 (\s @$\rightarrow$@ testStack03 s testStack032) +testStack04 = testStack02 (\s !$\rightarrow$! testStack03 s testStack032) -testStack05 : testStack04 @$\equiv$@ True +testStack05 : testStack04 !$\equiv$! True testStack05 = refl -testStack06 : {m : Level } @$\rightarrow$@ Maybe (Element @$\mathbb{N}$@) +testStack06 : {m : Level } !$\rightarrow$! Maybe (Element !$\mathbb{N}$!) testStack06 = pushStack createSingleLinkedStack 1 ( - \s @$\rightarrow$@ pushStack s 2 (\s @$\rightarrow$@ top (stack s))) + \s !$\rightarrow$! pushStack s 2 (\s !$\rightarrow$! top (stack s))) -testStack07 : {m : Level } @$\rightarrow$@ Maybe (Element @$\mathbb{N}$@) +testStack07 : {m : Level } !$\rightarrow$! Maybe (Element !$\mathbb{N}$!) testStack07 = pushSingleLinkedStack emptySingleLinkedStack 1 ( - \s @$\rightarrow$@ pushSingleLinkedStack s 2 (\s @$\rightarrow$@ top s)) + \s !$\rightarrow$! pushSingleLinkedStack s 2 (\s !$\rightarrow$! top s)) testStack08 = pushSingleLinkedStack emptySingleLinkedStack 1 - $ \s @$\rightarrow$@ pushSingleLinkedStack s 2 - $ \s @$\rightarrow$@ pushSingleLinkedStack s 3 - $ \s @$\rightarrow$@ pushSingleLinkedStack s 4 - $ \s @$\rightarrow$@ pushSingleLinkedStack s 5 - $ \s @$\rightarrow$@ top s + $ \s !$\rightarrow$! pushSingleLinkedStack s 2 + $ \s !$\rightarrow$! pushSingleLinkedStack s 3 + $ \s !$\rightarrow$! pushSingleLinkedStack s 4 + $ \s !$\rightarrow$! pushSingleLinkedStack s 5 + $ \s !$\rightarrow$! top s ------ -- @@ -84,61 +84,61 @@ -- this should be proved by properties of the stack inteface, not only by the implementation, -- and the implementation have to provides the properties. -- --- we cannot write "s @$\equiv$@ s3", since level of the Set does not fit , but use stack s @$\equiv$@ stack s3 is ok. +-- we cannot write "s !$\equiv$! s3", since level of the Set does not fit , but use stack s !$\equiv$! stack s3 is ok. -- anyway some implementations may result s != s3 -- -stackInSomeState : {l m : Level } {D : Set l} {t : Set m } (s : SingleLinkedStack D ) @$\rightarrow$@ Stack {l} {m} D {t} ( SingleLinkedStack D ) +stackInSomeState : {l m : Level } {D : Set l} {t : Set m } (s : SingleLinkedStack D ) !$\rightarrow$! Stack {l} {m} D {t} ( SingleLinkedStack D ) stackInSomeState s = record { stack = s ; stackMethods = singleLinkedStackSpec } -push@$\rightarrow$@push@$\rightarrow$@pop2 : {l : Level } {D : Set l} (x y : D ) (s : SingleLinkedStack D ) @$\rightarrow$@ - pushStack ( stackInSomeState s ) x ( \s1 @$\rightarrow$@ pushStack s1 y ( \s2 @$\rightarrow$@ pop2Stack s2 ( \s3 y1 x1 @$\rightarrow$@ (Just x @$\equiv$@ x1 ) @$\wedge$@ (Just y @$\equiv$@ y1 ) ) )) -push@$\rightarrow$@push@$\rightarrow$@pop2 {l} {D} x y s = record { pi1 = refl ; pi2 = refl } +push!$\rightarrow$!push!$\rightarrow$!pop2 : {l : Level } {D : Set l} (x y : D ) (s : SingleLinkedStack D ) !$\rightarrow$! + pushStack ( stackInSomeState s ) x ( \s1 !$\rightarrow$! pushStack s1 y ( \s2 !$\rightarrow$! pop2Stack s2 ( \s3 y1 x1 !$\rightarrow$! (Just x !$\equiv$! x1 ) !$\wedge$! (Just y !$\equiv$! y1 ) ) )) +push!$\rightarrow$!push!$\rightarrow$!pop2 {l} {D} x y s = record { pi1 = refl ; pi2 = refl } --- id : {n : Level} {A : Set n} @$\rightarrow$@ A @$\rightarrow$@ A +-- id : {n : Level} {A : Set n} !$\rightarrow$! A !$\rightarrow$! A -- id a = a -- push a, n times -n-push : {n : Level} {A : Set n} {a : A} @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ SingleLinkedStack A @$\rightarrow$@ SingleLinkedStack A +n-push : {n : Level} {A : Set n} {a : A} !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! SingleLinkedStack A !$\rightarrow$! SingleLinkedStack A n-push zero s = s -n-push {l} {A} {a} (suc n) s = pushSingleLinkedStack (n-push {l} {A} {a} n s) a (\s @$\rightarrow$@ s ) +n-push {l} {A} {a} (suc n) s = pushSingleLinkedStack (n-push {l} {A} {a} n s) a (\s !$\rightarrow$! s ) -n-pop : {n : Level}{A : Set n} {a : A} @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ SingleLinkedStack A @$\rightarrow$@ SingleLinkedStack A +n-pop : {n : Level}{A : Set n} {a : A} !$\rightarrow$! !$\mathbb{N}$! !$\rightarrow$! SingleLinkedStack A !$\rightarrow$! SingleLinkedStack A n-pop zero s = s -n-pop {_} {A} {a} (suc n) s = popSingleLinkedStack (n-pop {_} {A} {a} n s) (\s _ @$\rightarrow$@ s ) +n-pop {_} {A} {a} (suc n) s = popSingleLinkedStack (n-pop {_} {A} {a} n s) (\s _ !$\rightarrow$! s ) -open @$\equiv$@-Reasoning +open !$\equiv$!-Reasoning -push-pop-equiv : {n : Level} {A : Set n} {a : A} (s : SingleLinkedStack A) @$\rightarrow$@ (popSingleLinkedStack (pushSingleLinkedStack s a (\s @$\rightarrow$@ s)) (\s _ @$\rightarrow$@ s) ) @$\equiv$@ s +push-pop-equiv : {n : Level} {A : Set n} {a : A} (s : SingleLinkedStack A) !$\rightarrow$! (popSingleLinkedStack (pushSingleLinkedStack s a (\s !$\rightarrow$! s)) (\s _ !$\rightarrow$! s) ) !$\equiv$! s push-pop-equiv s = refl -push-and-n-pop : {n : Level} {A : Set n} {a : A} (n : @$\mathbb{N}$@) (s : SingleLinkedStack A) @$\rightarrow$@ n-pop {_} {A} {a} (suc n) (pushSingleLinkedStack s a id) @$\equiv$@ n-pop {_} {A} {a} n s +push-and-n-pop : {n : Level} {A : Set n} {a : A} (n : !$\mathbb{N}$!) (s : SingleLinkedStack A) !$\rightarrow$! n-pop {_} {A} {a} (suc n) (pushSingleLinkedStack s a id) !$\equiv$! n-pop {_} {A} {a} n s push-and-n-pop zero s = refl push-and-n-pop {_} {A} {a} (suc n) s = begin n-pop {_} {A} {a} (suc (suc n)) (pushSingleLinkedStack s a id) - @$\equiv$@@$\langle$@ refl @$\rangle$@ - popSingleLinkedStack (n-pop {_} {A} {a} (suc n) (pushSingleLinkedStack s a id)) (\s _ @$\rightarrow$@ s) - @$\equiv$@@$\langle$@ cong (\s @$\rightarrow$@ popSingleLinkedStack s (\s _ @$\rightarrow$@ s )) (push-and-n-pop n s) @$\rangle$@ - popSingleLinkedStack (n-pop {_} {A} {a} n s) (\s _ @$\rightarrow$@ s) - @$\equiv$@@$\langle$@ refl @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! + popSingleLinkedStack (n-pop {_} {A} {a} (suc n) (pushSingleLinkedStack s a id)) (\s _ !$\rightarrow$! s) + !$\equiv$!!$\langle$! cong (\s !$\rightarrow$! popSingleLinkedStack s (\s _ !$\rightarrow$! s )) (push-and-n-pop n s) !$\rangle$! + popSingleLinkedStack (n-pop {_} {A} {a} n s) (\s _ !$\rightarrow$! s) + !$\equiv$!!$\langle$! refl !$\rangle$! n-pop {_} {A} {a} (suc n) s - @$\blacksquare$@ + !$\blacksquare$! -n-push-pop-equiv : {n : Level} {A : Set n} {a : A} (n : @$\mathbb{N}$@) (s : SingleLinkedStack A) @$\rightarrow$@ (n-pop {_} {A} {a} n (n-push {_} {A} {a} n s)) @$\equiv$@ s +n-push-pop-equiv : {n : Level} {A : Set n} {a : A} (n : !$\mathbb{N}$!) (s : SingleLinkedStack A) !$\rightarrow$! (n-pop {_} {A} {a} n (n-push {_} {A} {a} n s)) !$\equiv$! s n-push-pop-equiv zero s = refl n-push-pop-equiv {_} {A} {a} (suc n) s = begin n-pop {_} {A} {a} (suc n) (n-push (suc n) s) - @$\equiv$@@$\langle$@ refl @$\rangle$@ - n-pop {_} {A} {a} (suc n) (pushSingleLinkedStack (n-push n s) a (\s @$\rightarrow$@ s)) - @$\equiv$@@$\langle$@ push-and-n-pop n (n-push n s) @$\rangle$@ + !$\equiv$!!$\langle$! refl !$\rangle$! + n-pop {_} {A} {a} (suc n) (pushSingleLinkedStack (n-push n s) a (\s !$\rightarrow$! s)) + !$\equiv$!!$\langle$! push-and-n-pop n (n-push n s) !$\rangle$! n-pop {_} {A} {a} n (n-push n s) - @$\equiv$@@$\langle$@ n-push-pop-equiv n s @$\rangle$@ + !$\equiv$!!$\langle$! n-push-pop-equiv n s !$\rangle$! s - @$\blacksquare$@ + !$\blacksquare$! -n-push-pop-equiv-empty : {n : Level} {A : Set n} {a : A} @$\rightarrow$@ (n : @$\mathbb{N}$@) @$\rightarrow$@ n-pop {_} {A} {a} n (n-push {_} {A} {a} n emptySingleLinkedStack) @$\equiv$@ emptySingleLinkedStack +n-push-pop-equiv-empty : {n : Level} {A : Set n} {a : A} !$\rightarrow$! (n : !$\mathbb{N}$!) !$\rightarrow$! n-pop {_} {A} {a} n (n-push {_} {A} {a} n emptySingleLinkedStack) !$\equiv$! emptySingleLinkedStack n-push-pop-equiv-empty n = n-push-pop-equiv n emptySingleLinkedStack diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/subtype.agda.replaced --- a/Paper/src/subtype.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/subtype.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -4,33 +4,33 @@ module subtype {l : Level} (Context : Set l) where -record DataSegment {ll : Level} (A : Set ll) : Set (l @$\sqcup$@ ll) where +record DataSegment {ll : Level} (A : Set ll) : Set (l !$\sqcup$! ll) where field - get : Context @$\rightarrow$@ A - set : Context @$\rightarrow$@ A @$\rightarrow$@ Context + get : Context !$\rightarrow$! A + set : Context !$\rightarrow$! A !$\rightarrow$! Context open DataSegment -data CodeSegment {l1 l2 : Level} (A : Set l1) (B : Set l2) : Set (l @$\sqcup$@ l1 @$\sqcup$@ l2) where - cs : {{_ : DataSegment A}} {{_ : DataSegment B}} @$\rightarrow$@ (A @$\rightarrow$@ B) @$\rightarrow$@ CodeSegment A B +data CodeSegment {l1 l2 : Level} (A : Set l1) (B : Set l2) : Set (l !$\sqcup$! l1 !$\sqcup$! l2) where + cs : {{_ : DataSegment A}} {{_ : DataSegment B}} !$\rightarrow$! (A !$\rightarrow$! B) !$\rightarrow$! CodeSegment A B -goto : {l1 l2 : Level} {I : Set l1} {O : Set l2} @$\rightarrow$@ CodeSegment I O @$\rightarrow$@ I @$\rightarrow$@ O +goto : {l1 l2 : Level} {I : Set l1} {O : Set l2} !$\rightarrow$! CodeSegment I O !$\rightarrow$! I !$\rightarrow$! O goto (cs b) i = b i exec : {l1 l2 : Level} {I : Set l1} {O : Set l2} {{_ : DataSegment I}} {{_ : DataSegment O}} - @$\rightarrow$@ CodeSegment I O @$\rightarrow$@ Context @$\rightarrow$@ Context + !$\rightarrow$! CodeSegment I O !$\rightarrow$! Context !$\rightarrow$! Context exec {l} {{i}} {{o}} (cs b) c = set o c (b (get i c)) -comp : {con : Context} @$\rightarrow$@ {l1 l2 l3 l4 : Level} +comp : {con : Context} !$\rightarrow$! {l1 l2 l3 l4 : Level} {A : Set l1} {B : Set l2} {C : Set l3} {D : Set l4} {{_ : DataSegment A}} {{_ : DataSegment B}} {{_ : DataSegment C}} {{_ : DataSegment D}} - @$\rightarrow$@ (C @$\rightarrow$@ D) @$\rightarrow$@ (A @$\rightarrow$@ B) @$\rightarrow$@ A @$\rightarrow$@ D + !$\rightarrow$! (C !$\rightarrow$! D) !$\rightarrow$! (A !$\rightarrow$! B) !$\rightarrow$! A !$\rightarrow$! D comp {con} {{i}} {{io}} {{oi}} {{o}} g f x = g (get oi (set io con (f x))) -csComp : {con : Context} @$\rightarrow$@ {l1 l2 l3 l4 : Level} +csComp : {con : Context} !$\rightarrow$! {l1 l2 l3 l4 : Level} {A : Set l1} {B : Set l2} {C : Set l3} {D : Set l4} {{_ : DataSegment A}} {{_ : DataSegment B}} {{_ : DataSegment C}} {{_ : DataSegment D}} - @$\rightarrow$@ CodeSegment C D @$\rightarrow$@ CodeSegment A B @$\rightarrow$@ CodeSegment A D + !$\rightarrow$! CodeSegment C D !$\rightarrow$! CodeSegment A B !$\rightarrow$! CodeSegment A D csComp {con} {A} {B} {C} {D} {{da}} {{db}} {{dc}} {{dd}} (cs g) (cs f) = cs {{da}} {{dd}} (comp {con} {{da}} {{db}} {{dc}} {{dd}} g f) @@ -39,6 +39,6 @@ comp-associative : {A B C D E F : Set l} {con : Context} {{da : DataSegment A}} {{db : DataSegment B}} {{dc : DataSegment C}} {{dd : DataSegment D}} {{de : DataSegment E}} {{df : DataSegment F}} - @$\rightarrow$@ (a : CodeSegment A B) (b : CodeSegment C D) (c : CodeSegment E F) - @$\rightarrow$@ csComp {con} c (csComp {con} b a) @$\equiv$@ csComp {con} (csComp {con} c b) a + !$\rightarrow$! (a : CodeSegment A B) (b : CodeSegment C D) (c : CodeSegment E F) + !$\rightarrow$! csComp {con} c (csComp {con} b a) !$\equiv$! csComp {con} (csComp {con} c b) a comp-associative (cs _) (cs _) (cs _) = refl diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/term1.agda.replaced --- a/Paper/src/term1.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/term1.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,15 +1,15 @@ -stmt2Cond : {c10 :@$\mathbb{N}$@} @$\rightarrow$@ Cond -stmt2Cond {c10} env = (Equal (varn env) c10) @$\wedge$@ (Equal (vari env) 0) +stmt2Cond : {c10 :!$\mathbb{N}$!} !$\rightarrow$! Cond +stmt2Cond {c10} env = (Equal (varn env) c10) !$\wedge$! (Equal (vari env) 0) -lemma1 : {c10 :@$\mathbb{N}$@} @$\rightarrow$@ Axiom (stmt1Cond {c10}) - (@$\lambda$@ env @$\rightarrow$@ record { varn = varn env ; vari = 0 }) (stmt2Cond {c10}) -lemma1 {c10} env = impl@$\Rightarrow$@ ( @$\lambda$@ cond @$\rightarrow$@ let open @$\equiv$@-Reasoning in +lemma1 : {c10 :!$\mathbb{N}$!} !$\rightarrow$! Axiom (stmt1Cond {c10}) + (!$\lambda$! env !$\rightarrow$! record { varn = varn env ; vari = 0 }) (stmt2Cond {c10}) +lemma1 {c10} env = impl!$\Rightarrow$! ( !$\lambda$! cond !$\rightarrow$! let open !$\equiv$!-Reasoning in begin ? -- ?0 - @$\equiv$@@$\langle$@ ? @$\rangle$@ -- ?1 + !$\equiv$!!$\langle$! ? !$\rangle$! -- ?1 ? -- ?2 - @$\blacksquare$@ ) + !$\blacksquare$! ) -- ?0 : Bool --- ?1 : stmt2Cond (record { varn = varn env ; vari = 0 }) @$\equiv$@ true +-- ?1 : stmt2Cond (record { varn = varn env ; vari = 0 }) !$\equiv$! true -- ?2 : Bool diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/term2.agda.replaced --- a/Paper/src/term2.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/term2.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,7 +1,7 @@ -@$\wedge$@true : { x : Bool } @$\rightarrow$@ x @$\wedge$@ true @$\equiv$@ x -@$\wedge$@true {x} with x -@$\wedge$@true {x} | false = refl -@$\wedge$@true {x} | true = refl +!$\wedge$!true : { x : Bool } !$\rightarrow$! x !$\wedge$! true !$\equiv$! x +!$\wedge$!true {x} with x +!$\wedge$!true {x} | false = refl +!$\wedge$!true {x} | true = refl -stmt1Cond : {c10 :@$\mathbb{N}$@} @$\rightarrow$@ Cond +stmt1Cond : {c10 :!$\mathbb{N}$!} !$\rightarrow$! Cond stmt1Cond {c10} env = Equal (varn env) c10 diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/term3.agda.replaced --- a/Paper/src/term3.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/term3.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,10 +1,10 @@ -lemma1 : {c10 :@$\mathbb{N}$@} @$\rightarrow$@ Axiom (stmt1Cond {c10}) (@$\lambda$@ env @$\rightarrow$@ record { varn = varn env ; vari = 0 }) (stmt2Cond {c\ +lemma1 : {c10 :!$\mathbb{N}$!} !$\rightarrow$! Axiom (stmt1Cond {c10}) (!$\lambda$! env !$\rightarrow$! record { varn = varn env ; vari = 0 }) (stmt2Cond {c\ 10}) -lemma1 {c10} env = impl@$\Rightarrow$@ ( @$\lambda$@ cond @$\rightarrow$@ let open @$\equiv$@-Reasoning in +lemma1 {c10} env = impl!$\Rightarrow$! ( !$\lambda$! cond !$\rightarrow$! let open !$\equiv$!-Reasoning in begin -(Equal (varn env) c10 ) @$\wedge$@ true -@$\equiv$@@$\langle$@ @$\wedge$@true @$\rangle$@ +(Equal (varn env) c10 ) !$\wedge$! true +!$\equiv$!!$\langle$! !$\wedge$!true !$\rangle$! Equal (varn env) c10 -@$\equiv$@@$\langle$@ cond @$\rangle$@ +!$\equiv$!!$\langle$! cond !$\rangle$! true -@$\blacksquare$@ ) +!$\blacksquare$! ) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/termination.agda.replaced --- a/Paper/src/termination.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/termination.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,11 +1,11 @@ -{-@$\#$@ TERMINATING @$\#$@-} -loop : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ +{-!$\#$! TERMINATING !$\#$!-} +loop : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! loop n = loop (pred n) --- pred : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ +-- pred : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! -- pred zero = zero -- pred (suc n) = n -stop : @$\mathbb{N}$@ @$\rightarrow$@ @$\mathbb{N}$@ +stop : !$\mathbb{N}$! !$\rightarrow$! !$\mathbb{N}$! stop zero = zero stop (suc n) = (stop n) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/tree.agda.replaced --- a/Paper/src/tree.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/tree.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,10 +1,10 @@ data nomal-tree (A : Set) : Set where - nleaf : (key : @$\mathbb{N}$@) @$\rightarrow$@ tree A - nnode : (key : @$\mathbb{N}$@) @$\rightarrow$@ (lnode : nomal-tree A) @$\rightarrow$@ (rnode : nomal-tree A) @$\rightarrow$@ nomal-tree A + nleaf : (key : !$\mathbb{N}$!) !$\rightarrow$! tree A + nnode : (key : !$\mathbb{N}$!) !$\rightarrow$! (lnode : nomal-tree A) !$\rightarrow$! (rnode : nomal-tree A) !$\rightarrow$! nomal-tree A -data meta-tree (A : Set) : (key : @$\mathbb{N}$@) @$\rightarrow$@ Set where - mleaf : (key : @$\mathbb{N}$@) @$\rightarrow$@ meta-tree A key - mnode : { l r : @$\mathbb{N}$@ } @$\rightarrow$@ (key : @$\mathbb{N}$@) @$\rightarrow$@ (value : A) - @$\rightarrow$@ (lnode : meta-tree A l) @$\rightarrow$@ (rnode : meta-tree A r) - @$\rightarrow$@ l @$\leq$@ key @$\rightarrow$@ key @$\leq$@ r @$\rightarrow$@ metatree A key +data meta-tree (A : Set) : (key : !$\mathbb{N}$!) !$\rightarrow$! Set where + mleaf : (key : !$\mathbb{N}$!) !$\rightarrow$! meta-tree A key + mnode : { l r : !$\mathbb{N}$! } !$\rightarrow$! (key : !$\mathbb{N}$!) !$\rightarrow$! (value : A) + !$\rightarrow$! (lnode : meta-tree A l) !$\rightarrow$! (rnode : meta-tree A r) + !$\rightarrow$! l !$\leq$! key !$\rightarrow$! key !$\leq$! r !$\rightarrow$! metatree A key diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/while-test.agda.replaced --- a/Paper/src/while-test.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/while-test.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,2 +1,2 @@ -whileTest : {l : Level} {t : Set l} @$\rightarrow$@ (c10 : @$\mathbb{N}$@) @$\rightarrow$@ (Code : Env @$\rightarrow$@ t) @$\rightarrow$@ t +whileTest : {l : Level} {t : Set l} !$\rightarrow$! (c10 : !$\mathbb{N}$!) !$\rightarrow$! (Code : Env !$\rightarrow$! t) !$\rightarrow$! t whileTest c10 next = next (record {varn = c10 ; vari = 0} ) diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/while_loop_impl/init_cg.agda.replaced --- a/Paper/src/while_loop_impl/init_cg.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/while_loop_impl/init_cg.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,2 +1,2 @@ -whileTest : {l : Level} {t : Set l} @$\rightarrow$@ (c10 : @$\mathbb{N}$@) @$\rightarrow$@ (Code : Env @$\rightarrow$@ t) @$\rightarrow$@ t +whileTest : {l : Level} {t : Set l} !$\rightarrow$! (c10 : !$\mathbb{N}$!) !$\rightarrow$! (Code : Env !$\rightarrow$! t) !$\rightarrow$! t whileTest c10 next = next (record {varn = c10 ; vari = 0} ) \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/while_loop_impl/while_loop.agda.replaced --- a/Paper/src/while_loop_impl/while_loop.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/while_loop_impl/while_loop.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,5 +1,5 @@ -{-@$\#$@ TERMINATING @$\#$@-} -whileLoop : {l : Level} {t : Set l} @$\rightarrow$@ Env @$\rightarrow$@ (Code : Env @$\rightarrow$@ t) @$\rightarrow$@ t +{-!$\#$! TERMINATING !$\#$!-} +whileLoop : {l : Level} {t : Set l} !$\rightarrow$! Env !$\rightarrow$! (Code : Env !$\rightarrow$! t) !$\rightarrow$! t whileLoop env next with lt 0 (varn env) whileLoop env next | false = next env whileLoop env next | true = whileLoop (record {varn = (varn env) - 1 ; vari = (vari env) + 1}) next \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/while_loop_impl/while_loop_c.agda.replaced --- a/Paper/src/while_loop_impl/while_loop_c.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/while_loop_impl/while_loop_c.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,2 +1,2 @@ -whileLoopC : @$\mathbb{N}$@ @$\rightarrow$@ Env -whileLoopC n = whileTest n (@$\lambda$@ env @$\rightarrow$@ whileLoop env (@$\lambda$@ env1 @$\rightarrow$@ env1 )) \ No newline at end of file +whileLoopC : !$\mathbb{N}$! !$\rightarrow$! Env +whileLoopC n = whileTest n (!$\lambda$! env !$\rightarrow$! whileLoop env (!$\lambda$! env1 !$\rightarrow$! env1 )) \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/while_loop_impl/while_loop_dg.agda.replaced --- a/Paper/src/while_loop_impl/while_loop_dg.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/while_loop_impl/while_loop_dg.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,5 +1,5 @@ record Env : Set where field - varn : @$\mathbb{N}$@ - vari : @$\mathbb{N}$@ + varn : !$\mathbb{N}$! + vari : !$\mathbb{N}$! open Env \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/while_loop_verif/conversion.agda.replaced --- a/Paper/src/while_loop_verif/conversion.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/while_loop_verif/conversion.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,10 +1,10 @@ -conversion1 : {l : Level} {t : Set l } @$\rightarrow$@ (env : Env) @$\rightarrow$@ {c10 : @$\mathbb{N}$@ } @$\rightarrow$@ ((vari env) @$\equiv$@ 0) @$\wedge$@ ((varn env) @$\equiv$@ c10) - @$\rightarrow$@ (Code : (env1 : Env) @$\rightarrow$@ (varn env1 + vari env1 @$\equiv$@ c10) @$\rightarrow$@ t) @$\rightarrow$@ t +conversion1 : {l : Level} {t : Set l } !$\rightarrow$! (env : Env) !$\rightarrow$! {c10 : !$\mathbb{N}$! } !$\rightarrow$! ((vari env) !$\equiv$! 0) !$\wedge$! ((varn env) !$\equiv$! c10) + !$\rightarrow$! (Code : (env1 : Env) !$\rightarrow$! (varn env1 + vari env1 !$\equiv$! c10) !$\rightarrow$! t) !$\rightarrow$! t conversion1 env {c10} p1 next = next env proof4 where - proof4 : varn env + vari env @$\equiv$@ c10 - proof4 = let open @$\equiv$@-Reasoning in begin - varn env + vari env @$\equiv$@@$\langle$@ cong ( @$\lambda$@ n @$\rightarrow$@ n + vari env ) (pi2 p1 ) @$\rangle$@ - c10 + vari env @$\equiv$@@$\langle$@ cong ( @$\lambda$@ n @$\rightarrow$@ c10 + n ) (pi1 p1 ) @$\rangle$@ - c10 + 0 @$\equiv$@@$\langle$@ +-sym {c10} {0} @$\rangle$@ + proof4 : varn env + vari env !$\equiv$! c10 + proof4 = let open !$\equiv$!-Reasoning in begin + varn env + vari env !$\equiv$!!$\langle$! cong ( !$\lambda$! n !$\rightarrow$! n + vari env ) (pi2 p1 ) !$\rangle$! + c10 + vari env !$\equiv$!!$\langle$! cong ( !$\lambda$! n !$\rightarrow$! c10 + n ) (pi1 p1 ) !$\rangle$! + c10 + 0 !$\equiv$!!$\langle$! +-sym {c10} {0} !$\rangle$! c10 - @$\blacksquare$@ \ No newline at end of file + !$\blacksquare$! \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/while_loop_verif/init_cg.agda.replaced --- a/Paper/src/while_loop_verif/init_cg.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/while_loop_verif/init_cg.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,7 +1,7 @@ -whileTest@$\prime$@ : {l : Level} {t : Set l} @$\rightarrow$@ {c10 : @$\mathbb{N}$@ } @$\rightarrow$@ (Code : (env : Env) @$\rightarrow$@ ((vari env) @$\equiv$@ 0) @$\wedge$@ ((varn env) @$\equiv$@ c10) @$\rightarrow$@ t) @$\rightarrow$@ t -whileTest@$\prime$@ {_} {_} {c10} next = next env proof2 +whileTest!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! {c10 : !$\mathbb{N}$! } !$\rightarrow$! (Code : (env : Env) !$\rightarrow$! ((vari env) !$\equiv$! 0) !$\wedge$! ((varn env) !$\equiv$! c10) !$\rightarrow$! t) !$\rightarrow$! t +whileTest!$\prime$! {_} {_} {c10} next = next env proof2 where env : Env env = record {vari = 0 ; varn = c10} - proof2 : ((vari env) @$\equiv$@ 0) @$\wedge$@ ((varn env) @$\equiv$@ c10) -- PostCondition + proof2 : ((vari env) !$\equiv$! 0) !$\wedge$! ((varn env) !$\equiv$! c10) -- PostCondition proof2 = record {pi1 = refl ; pi2 = refl} diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/while_loop_verif/verif.agda.replaced --- a/Paper/src/while_loop_verif/verif.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/while_loop_verif/verif.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,4 +1,4 @@ -proofGearsTermS : {c10 : @$\mathbb{N}$@ } @$\rightarrow$@ @$\top$@ -proofGearsTermS {c10} = whileTest@$\prime$@ {_} {_} {c10} (@$\lambda$@ n p @$\rightarrow$@ conversion1 n p (@$\lambda$@ n1 p1 @$\rightarrow$@ - TerminatingLoopS Env (@$\lambda$@ env @$\rightarrow$@ varn env) - (@$\lambda$@ n2 p2 loop @$\rightarrow$@ whileLoopSeg {_} {_} {c10} n2 p2 loop (@$\lambda$@ ne pe @$\rightarrow$@ whileTestSpec1 c10 ne pe)) n1 p1 )) \ No newline at end of file +proofGearsTermS : {c10 : !$\mathbb{N}$! } !$\rightarrow$! !$\top$! +proofGearsTermS {c10} = whileTest!$\prime$! {_} {_} {c10} (!$\lambda$! n p !$\rightarrow$! conversion1 n p (!$\lambda$! n1 p1 !$\rightarrow$! + TerminatingLoopS Env (!$\lambda$! env !$\rightarrow$! varn env) + (!$\lambda$! n2 p2 loop !$\rightarrow$! whileLoopSeg {_} {_} {c10} n2 p2 loop (!$\lambda$! ne pe !$\rightarrow$! whileTestSpec1 c10 ne pe)) n1 p1 )) \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/while_loop_verif/verif_loop.agda.replaced --- a/Paper/src/while_loop_verif/verif_loop.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/while_loop_verif/verif_loop.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,12 +1,12 @@ -TerminatingLoopS : {l : Level} {t : Set l} (Index : Set ) @$\rightarrow$@ {Invraiant : Index @$\rightarrow$@ Set } @$\rightarrow$@ ( reduce : Index @$\rightarrow$@ @$\mathbb{N}$@) - @$\rightarrow$@ (loop : (r : Index) @$\rightarrow$@ Invraiant r @$\rightarrow$@ (next : (r1 : Index) @$\rightarrow$@ Invraiant r1 @$\rightarrow$@ reduce r1 < reduce r @$\rightarrow$@ t ) @$\rightarrow$@ t) - @$\rightarrow$@ (r : Index) @$\rightarrow$@ (p : Invraiant r) @$\rightarrow$@ t +TerminatingLoopS : {l : Level} {t : Set l} (Index : Set ) !$\rightarrow$! {Invraiant : Index !$\rightarrow$! Set } !$\rightarrow$! ( reduce : Index !$\rightarrow$! !$\mathbb{N}$!) + !$\rightarrow$! (loop : (r : Index) !$\rightarrow$! Invraiant r !$\rightarrow$! (next : (r1 : Index) !$\rightarrow$! Invraiant r1 !$\rightarrow$! reduce r1 < reduce r !$\rightarrow$! t ) !$\rightarrow$! t) + !$\rightarrow$! (r : Index) !$\rightarrow$! (p : Invraiant r) !$\rightarrow$! t TerminatingLoopS {_} {t} Index {Invraiant} reduce loop r p with <-cmp 0 (reduce r) -... | tri≈ @$\neg$@a b @$\neg$@c = loop r p (@$\lambda$@ r1 p1 lt @$\rightarrow$@ @$\bot$@-elim (lemma3 b lt) ) -... | tri< a @$\neg$@b @$\neg$@c = loop r p (@$\lambda$@ r1 p1 lt1 @$\rightarrow$@ TerminatingLoop1 (reduce r) r r1 (@$\leq$@-step lt1) p1 lt1 ) where - TerminatingLoop1 : (j : @$\mathbb{N}$@) @$\rightarrow$@ (r r1 : Index) @$\rightarrow$@ reduce r1 < suc j @$\rightarrow$@ Invraiant r1 @$\rightarrow$@ reduce r1 < reduce r @$\rightarrow$@ t - TerminatingLoop1 zero r r1 n@$\leq$@j p1 lt = loop r1 p1 (@$\lambda$@ r2 p1 lt1 @$\rightarrow$@ @$\bot$@-elim (lemma5 n@$\leq$@j lt1)) - TerminatingLoop1 (suc j) r r1 n@$\leq$@j p1 lt with <-cmp (reduce r1) (suc j) - ... | tri< a @$\neg$@b @$\neg$@c = TerminatingLoop1 j r r1 a p1 lt - ... | tri≈ @$\neg$@a b @$\neg$@c = loop r1 p1 (@$\lambda$@ r2 p2 lt1 @$\rightarrow$@ TerminatingLoop1 j r1 r2 (subst (@$\lambda$@ k @$\rightarrow$@ reduce r2 < k ) b lt1 ) p2 lt1 ) - ... | tri> @$\neg$@a @$\neg$@b c = @$\bot$@-elim ( nat-@$\leq$@> c n@$\leq$@j ) \ No newline at end of file +... | tri!$\approx$! !$\neg$!a b !$\neg$!c = loop r p (!$\lambda$! r1 p1 lt !$\rightarrow$! !$\bot$!-elim (lemma3 b lt) ) +... | tri< a !$\neg$!b !$\neg$!c = loop r p (!$\lambda$! r1 p1 lt1 !$\rightarrow$! TerminatingLoop1 (reduce r) r r1 (!$\leq$!-step lt1) p1 lt1 ) where + TerminatingLoop1 : (j : !$\mathbb{N}$!) !$\rightarrow$! (r r1 : Index) !$\rightarrow$! reduce r1 < suc j !$\rightarrow$! Invraiant r1 !$\rightarrow$! reduce r1 < reduce r !$\rightarrow$! t + TerminatingLoop1 zero r r1 n!$\leq$!j p1 lt = loop r1 p1 (!$\lambda$! r2 p1 lt1 !$\rightarrow$! !$\bot$!-elim (lemma5 n!$\leq$!j lt1)) + TerminatingLoop1 (suc j) r r1 n!$\leq$!j p1 lt with <-cmp (reduce r1) (suc j) + ... | tri< a !$\neg$!b !$\neg$!c = TerminatingLoop1 j r r1 a p1 lt + ... | tri!$\approx$! !$\neg$!a b !$\neg$!c = loop r1 p1 (!$\lambda$! r2 p2 lt1 !$\rightarrow$! TerminatingLoop1 j r1 r2 (subst (!$\lambda$! k !$\rightarrow$! reduce r2 < k ) b lt1 ) p2 lt1 ) + ... | tri> !$\neg$!a !$\neg$!b c = !$\bot$!-elim ( nat-!$\leq$!> c n!$\leq$!j ) \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/while_loop_verif/verif_term.agda.replaced --- a/Paper/src/while_loop_verif/verif_term.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/while_loop_verif/verif_term.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,5 +1,5 @@ -whileTestSpec1 : (c10 : @$\mathbb{N}$@) @$\rightarrow$@ (e1 : Env ) @$\rightarrow$@ vari e1 @$\equiv$@ c10 @$\rightarrow$@ @$\top$@ +whileTestSpec1 : (c10 : !$\mathbb{N}$!) !$\rightarrow$! (e1 : Env ) !$\rightarrow$! vari e1 !$\equiv$! c10 !$\rightarrow$! !$\top$! whileTestSpec1 _ _ x = tt -proofGears : {c10 : @$\mathbb{N}$@ } @$\rightarrow$@ @$\top$@ -proofGears {c10} = whileTest@$\prime$@ {_} {_} {c10} (@$\lambda$@ n p1 @$\rightarrow$@ conversion1 n p1 (@$\lambda$@ n1 p2 @$\rightarrow$@ whileLoop@$\prime$@ n1 p2 (@$\lambda$@ n2 p3 @$\rightarrow$@ whileTestSpec1 c10 n2 p3 ))) \ No newline at end of file +proofGears : {c10 : !$\mathbb{N}$! } !$\rightarrow$! !$\top$! +proofGears {c10} = whileTest!$\prime$! {_} {_} {c10} (!$\lambda$! n p1 !$\rightarrow$! conversion1 n p1 (!$\lambda$! n1 p2 !$\rightarrow$! whileLoop!$\prime$! n1 p2 (!$\lambda$! n2 p3 !$\rightarrow$! whileTestSpec1 c10 n2 p3 ))) \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/while_loop_verif/while_loop.agda.replaced --- a/Paper/src/while_loop_verif/while_loop.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/while_loop_verif/while_loop.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,24 +1,24 @@ -{-@$\#$@ TERMINATING @$\#$@-} -whileLoop@$\prime$@ : {l : Level} {t : Set l} @$\rightarrow$@ (env : Env) @$\rightarrow$@ {c10 : @$\mathbb{N}$@ } @$\rightarrow$@ ((varn env) + (vari env) @$\equiv$@ c10) - @$\rightarrow$@ (Code : (e1 : Env )@$\rightarrow$@ vari e1 @$\equiv$@ c10 @$\rightarrow$@ t) @$\rightarrow$@ t -whileLoop@$\prime$@ env proof next with ( suc zero @$\leq$@? (varn env) ) -whileLoop@$\prime$@ env {c10} proof next | no p = next env ( begin - vari env @$\equiv$@@$\langle$@ refl @$\rangle$@ - 0 + vari env @$\equiv$@@$\langle$@ cong (@$\lambda$@ k @$\rightarrow$@ k + vari env) (sym (lemma1 p )) @$\rangle$@ - varn env + vari env @$\equiv$@@$\langle$@ proof @$\rangle$@ - c10 @$\blacksquare$@ ) where open @$\equiv$@-Reasoning -whileLoop@$\prime$@ env {c10} proof next | yes p = whileLoop@$\prime$@ env1 (proof3 p ) next where +{-!$\#$! TERMINATING !$\#$!-} +whileLoop!$\prime$! : {l : Level} {t : Set l} !$\rightarrow$! (env : Env) !$\rightarrow$! {c10 : !$\mathbb{N}$! } !$\rightarrow$! ((varn env) + (vari env) !$\equiv$! c10) + !$\rightarrow$! (Code : (e1 : Env )!$\rightarrow$! vari e1 !$\equiv$! c10 !$\rightarrow$! t) !$\rightarrow$! t +whileLoop!$\prime$! env proof next with ( suc zero !$\leq$!? (varn env) ) +whileLoop!$\prime$! env {c10} proof next | no p = next env ( begin + vari env !$\equiv$!!$\langle$! refl !$\rangle$! + 0 + vari env !$\equiv$!!$\langle$! cong (!$\lambda$! k !$\rightarrow$! k + vari env) (sym (lemma1 p )) !$\rangle$! + varn env + vari env !$\equiv$!!$\langle$! proof !$\rangle$! + c10 !$\blacksquare$! ) where open !$\equiv$!-Reasoning +whileLoop!$\prime$! env {c10} proof next | yes p = whileLoop!$\prime$! env1 (proof3 p ) next where env1 = record {varn = (varn env) - 1 ; vari = (vari env) + 1} - 1<0 : 1 @$\leq$@ zero @$\rightarrow$@ @$\bot$@ + 1<0 : 1 !$\leq$! zero !$\rightarrow$! !$\bot$! 1<0 () - proof3 : (suc zero @$\leq$@ (varn env)) @$\rightarrow$@ varn env1 + vari env1 @$\equiv$@ c10 - proof3 (s@$\leq$@s lt) with varn env - proof3 (s@$\leq$@s z@$\leq$@n) | zero = @$\bot$@-elim (1<0 p) - proof3 (s@$\leq$@s (z@$\leq$@n {n@$\prime$@}) ) | suc n = let open @$\equiv$@-Reasoning in begin - n@$\prime$@ + (vari env + 1) @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ n@$\prime$@ + z ) ( +-sym {vari env} {1} ) @$\rangle$@ - n@$\prime$@ + (1 + vari env ) @$\equiv$@@$\langle$@ sym ( +-assoc (n@$\prime$@) 1 (vari env) ) @$\rangle$@ - (n@$\prime$@ + 1) + vari env @$\equiv$@@$\langle$@ cong ( @$\lambda$@ z @$\rightarrow$@ z + vari env ) +1@$\equiv$@suc @$\rangle$@ - (suc n@$\prime$@ ) + vari env @$\equiv$@@$\langle$@@$\rangle$@ - varn env + vari env @$\equiv$@@$\langle$@ proof @$\rangle$@ + proof3 : (suc zero !$\leq$! (varn env)) !$\rightarrow$! varn env1 + vari env1 !$\equiv$! c10 + proof3 (s!$\leq$!s lt) with varn env + proof3 (s!$\leq$!s z!$\leq$!n) | zero = !$\bot$!-elim (1<0 p) + proof3 (s!$\leq$!s (z!$\leq$!n {n!$\prime$!}) ) | suc n = let open !$\equiv$!-Reasoning in begin + n!$\prime$! + (vari env + 1) !$\equiv$!!$\langle$! cong ( !$\lambda$! z !$\rightarrow$! n!$\prime$! + z ) ( +-sym {vari env} {1} ) !$\rangle$! + n!$\prime$! + (1 + vari env ) !$\equiv$!!$\langle$! sym ( +-assoc (n!$\prime$!) 1 (vari env) ) !$\rangle$! + (n!$\prime$! + 1) + vari env !$\equiv$!!$\langle$! cong ( !$\lambda$! z !$\rightarrow$! z + vari env ) +1!$\equiv$!suc !$\rangle$! + (suc n!$\prime$! ) + vari env !$\equiv$!!$\langle$!!$\rangle$! + varn env + vari env !$\equiv$!!$\langle$! proof !$\rangle$! c10 - @$\blacksquare$@ \ No newline at end of file + !$\blacksquare$! \ No newline at end of file diff -r 72667e8198e2 -r 339fb67b4375 Paper/src/zero.agda.replaced --- a/Paper/src/zero.agda.replaced Sat Nov 06 20:06:24 2021 +0900 +++ b/Paper/src/zero.agda.replaced Sun Nov 07 00:51:16 2021 +0900 @@ -1,3 +1,3 @@ -+zero : { y : @$\mathbb{N}$@ } @$\rightarrow$@ y + zero @$\equiv$@ y ++zero : { y : !$\mathbb{N}$! } !$\rightarrow$! y + zero !$\equiv$! y +zero {zero} = refl +zero {suc y} = cong suc ( +zero {y} ) diff -r 72667e8198e2 -r 339fb67b4375 Paper/tex/tree_desc.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/tex/tree_desc.tex Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,89 @@ +\section{Gears Agda における木構造の設計} + +本研究では、Gears Agda にて Red Black Tree の検証を行うにあたり、 +Agda が変数に対して再代入を許していないことが問題になってくる。 + +そのため下図のように、木構造の root から leaf に 辿る際に見ているnodeから +下の tree をそのまま stack に持つようにする。 + +そして insert や delete を行った後に stack から tree を取り出し、 +元の木構造を再構築 していきながら rootへ戻る。 + +このようにして Gears Agda にて Red Black Tree を実装していく。 + +\section{Gears Agda における Binary Tree の実装} + +Red Black Tree を実装しそれを検証する前段階として、 +実装が簡単な Binary Tree の実装から行う。 + +まず Binary Tree と 遷移させる Data Gear となる Env の定義は Code \ref{bt_env} のようになる。 + +\lstinputlisting[label=bt_env, caption=Binary Tree の Data Gear] {src/bt_impl/bt_env.agda.replaced} + +bt は、木での順序としての意味を持つ key とその中身 value はどのような型でも入れられるように +「A : Set n」となっている。 +そして left, right には bt A を持つようにし、木構造を構築している。 + +Env では、 find, insert, delete の対象となる値を保存し、 Code Gear に与えられるようにするために +varn, varv を持っている。 +加えて変更を加える bt を持つ vart と、章Nで前述した木構造を持っておくための List である +varl を Env に設定している。 + +7章で述べた Gears Agda での木構造を保ったまま root から目的のnodeまで辿る Code Gear が +Code \ref{bt_find_impl} になる。 + +\lstinputlisting[label=bt_find_impl, caption=root から目的のnodeまで辿る Code Gear] {src/bt_impl/find.agda.replaced} + +まず、関数の実装が始まってすぐに Env の vartを指定したものと引数をそのまま find-c の関数に遷移している。 +ここで展開しているのは Env の vart で、そのまま Env から展開した vart をパターンマッチすると +Agda が追えなくなってしまい、\{-$\#$ TERMINATING $\#$-\} を使用することになってしまう。 + +そのため関数を新たに定義し、展開したものを受け取り、パターンマッチすることで +\{-$\#$ TERMINATING $\#$-\} を使用せずに loopを定義できるようになる + +木を stack に入れるのは単純で、操作の対象の key となる varn と +node のkeyを比較を行う。 +そこからは本来の木構造と同じで、操作の対象の key が小さいなら +left の tree を次の node として遷移する。 +大きいなら right の tree を次の node として遷移していく。 + +操作の対象となる node に辿り着き、操作を行った後、 +Stack に持っている tree から再構築を行う。 + +そのコードが Code \ref{bt_replace_impl} となる + +\lstinputlisting[label=bt_replace_impl, caption=Stack から tree を再構築する Code Gear] {src/bt_impl/replace.agda.replaced} + +これも Code \ref{bt_find_impl} と同じように構成されており、 +varn と node の key を比較し、 vart を List から持ってきた node の どこに加えるかを決めるようになっている。 + +以上の流れを繋げることで、 Binary Tree の insert と find を実装できた。 +delete は insert の値を消すようにすると実装ができる。 + +\section{Gears Agda における Binary Tree の検証} + +検証も前述した While Loop の 検証と同じようにしていく。 +しかし、 Binary Tree の不変条件は2つ以上あるため、これを関数定義の際に全て書くと +煩雑になってしまうため、事前に記述して関数化しておく。 +それが Code \ref{bt_invariant} になる。 + +\lstinputlisting[label=bt_invariant, caption=Binary Tree の 不変条件] {src/bt_verif/invariant.agda.replaced} + +この不変条件は、 treeInvariant が tree の 左にある node の key が小さく、 +右にある node の方が大きいことを条件としている。 + +stackInvariant は Stack にある tree が、次に取り出す Tree の一部であることを +条件としている。 + +これを先ほど実装した Code Gear に対して加えることで検証していく。 +先ほど実装した Code \ref{bt_find_impl} に対して加えると Code ref のようになる。 + + +\lstinputlisting[label=bt_invariant, caption=Binary Tree の 不変条件] {src/bt_verif/find.agda.replaced} + +現時点では条件を満たしていることの証明まで行っていないが +コード中の {!!} に記述を行い、前述した While Loop と同じように中身を記述することで検証を行える。 + + + + diff -r 72667e8198e2 -r 339fb67b4375 bt/bt.agda --- a/bt/bt.agda Sat Nov 06 20:06:24 2021 +0900 +++ b/bt/bt.agda Sun Nov 07 00:51:16 2021 +0900 @@ -7,8 +7,31 @@ open import Data.Nat.Properties as NatProp -- <-cmp open import Relation.Binary +open import Relation.Binary.PropositionalEquality +open import Relation.Nullary +open import Data.Product + open import Function as F hiding (const) +open import Level renaming (zero to Z ; suc to succ) + +open import Data.Nat hiding (compare) +open import Data.Nat.Properties as NatProp +open import Data.Maybe +-- open import Data.Maybe.Properties +open import Data.Empty +open import Data.List +open import Data.Product + +open import Function as F hiding (const) + +open import Relation.Binary +open import Relation.Binary.PropositionalEquality +open import Relation.Nullary +open import logic + +open import logic + data bt {n : Level} (A : Set n) : Set n where leaf : bt A node : (key-t : ℕ) → (value : A) → @@ -22,6 +45,10 @@ varl : List (bt A) open Env +bt-depth : {n : Level} {a : Set n} → (tree : bt a ) → ℕ +bt-depth leaf = 0 +bt-depth (node key value ltree rtree) = suc (Data.Nat._⊔_ (bt-depth ltree) (bt-depth rtree)) + bt-depth1 : {n : Level} {A : Set n} → (env : Env A ) → ℕ bt-depth1 env with vart env ... | tree = bt-depth-c tree where @@ -35,22 +62,22 @@ test-depth1 : ℕ test-depth1 = bt-depth1 record {varn = 0; varv = 4; vart = (node 3 0 leaf (node 1 1 leaf (node 3 5 leaf leaf))); varl = []} -find1 : {n m : Level} {A : Set n} {t : Set m} → (env : Env A ) +find : {n m : Level} {A : Set n} {t : Set m} → (env : Env A ) → (next : (env : Env A ) → t ) → (exit : (env : Env A ) → t ) → t -find1 env next exit = find1-c (varn env) (vart env) env next exit where - find1-c : {n m : Level} {A : Set n} {t : Set m} → (key : ℕ) → (tree : bt A) → (env : Env A ) +find env next exit = find-c (vart env) env next exit where + find-c : {n m : Level} {A : Set n} {t : Set m} → (tree : bt A) → (env : Env A ) → (next : (env : Env A ) → t ) → (exit : (env : Env A ) → t ) → t - find1-c key leaf env next exit = exit env - find1-c key n@(node key-t value ltree rtree) env next exit with <-cmp key key-t - ... | tri< a ¬b ¬c = find1-c key ltree record env {vart = ltree ; varl = (n ∷ (varl env))} next exit + find-c leaf env next exit = exit env + find-c n@(node key-t value ltree rtree) env next exit with <-cmp (varn env) key-t + ... | tri< a ¬b ¬c = find-c ltree record env {vart = ltree ; varl = (n ∷ (varl env))} next exit ... | tri≈ ¬a b ¬c = exit record env {vart = n} - ... | tri> ¬a ¬b c = find1-c key rtree record env {vart = rtree ; varl = (n ∷ (varl env))} next exit + ... | tri> ¬a ¬b c = find-c rtree record env {vart = rtree ; varl = (n ∷ (varl env))} next exit find-loop-1 : {n m : Level} {A : Set n} {t : Set m} → (env : Env A ) → (exit : (env : Env A ) → t) → t -find-loop-1 env exit = find1 env exit exit +find-loop-1 env exit = find env exit exit fin-cg : {n m : Level} {A : Set n} {t : Set m} → t → (env : Env A ) → Env A fin-cg t = (λ env → env ) @@ -63,24 +90,24 @@ ... | leaf = next record env {vart = (node (varn env) (varv env) leaf leaf) } ... | node key-t value ltree rtree = next record env {vart = (node (varn env) (varv env) ltree rtree) } -replace1 : {n m : Level} {A : Set n} {t : Set m} → (env : Env A ) +replace : {n m : Level} {A : Set n} {t : Set m} → (env : Env A ) → (next : Env A → t ) → (exit : Env A → t) → t -replace1 env next exit = replace1-c (varl env) env next exit where - replace1-c : {n m : Level} {A : Set n} {t : Set m} → List (bt A) → (env : Env A ) - → (next : Env A → t ) +replace env next exit = replace-c (varl env) env next exit where + replace-c : {n m : Level} {A : Set n} {t : Set m} → List (bt A) → (env : Env A) + → (next : Env A → t) → (exit : Env A → t) → t - replace1-c st env next exit with st + replace-c st env next exit with st ... | [] = exit env - ... | leaf ∷ st1 = replace1-c st1 env next exit + ... | leaf ∷ st1 = replace-c st1 env next exit ... | n@(node key-t value ltree rtree) ∷ st1 with <-cmp (varn env) (key-t) - ... | tri< a ¬b ¬c = replace1-c st1 record env{vart = (node key-t value (vart env) rtree); varl = st1} next exit - ... | tri≈ ¬a b ¬c = replace1-c st1 record env{vart = (node key-t (varv env) ltree rtree); varl = st1} next exit - ... | tri> ¬a ¬b c = replace1-c st1 record env{vart = (node key-t value ltree (vart env)); varl = st1} next exit + ... | tri< a ¬b ¬c = replace-c st1 record env{vart = (node key-t value (vart env) rtree); varl = st1} next exit + ... | tri≈ ¬a b ¬c = replace-c st1 record env{vart = (node key-t (varv env) ltree rtree); varl = st1} next exit + ... | tri> ¬a ¬b c = replace-c st1 record env{vart = (node key-t value ltree (vart env)); varl = st1} next exit replace-loop1 : {n m : Level} {A : Set n} {t : Set m} → (env : Env A ) → (exit : (env : Env A ) → t) → t -replace-loop1 env exit = replace1 env exit exit +replace-loop1 env exit = replace env exit exit insertTree1 : {n m : Level} {A : Set n} {t : Set m} → (tree : bt A) → (key : ℕ) → (value : A) → (next : Env A → t ) → t insertTree1 tree key value exit = find-loop-1 record{varn = key; varv = value; vart = tree ; varl = []} @@ -95,4 +122,64 @@ test-insert1 = replaceTree1 (node 2 2 (node 1 1 leaf leaf) (node 4 4 leaf (node 5 5 leaf leaf))) 0 5 (λ env → env ) +open import Data.Unit hiding ( _≟_ ; _≤?_ ; _≤_) + +treeInvariant : {n : Level} {A : Set n} → (env : Env A) → Set n +treeInvariant env = treeInvariant-c (vart env) env where + treeInvariant-c : {n : Level} {A : Set n} → (tree : bt A) → (env : Env A) → Set n + treeInvariant-c tree env with tree + ... | leaf = Lift _ ⊤ + ... | node key-t value leaf leaf = Lift _ ⊤ + ... | node key-t value leaf rt@(node rkey-t rvalue rltree rrtree₁) = (key-t < rkey-t) ∧ treeInvariant-c rt env + ... | node key-t value lt@(node lkey-t lvalue lltree lrtree) leaf = treeInvariant-c lt env ∧ (lkey-t < key-t) + ... | node key-t value lt@(node lkey-t lvalue lltree lrtree) rt@(node rkey-t rvalue rltree rrtree) = treeInvariant-c lt env ∧ (lkey-t < key-t ) ∧ (key-t < rkey-t) ∧ treeInvariant-c rt env + +treeInvariant1 : {n : Level} {A : Set n} → (tree : bt A) → Set +treeInvariant1 leaf = ⊤ +treeInvariant1 (node key value leaf leaf) = ⊤ +treeInvariant1 (node key value leaf n@(node key₁ value₁ t₁ t₂)) = (key < key₁) ∧ treeInvariant1 n +treeInvariant1 (node key value n@(node key₁ value₁ t t₁) leaf) = treeInvariant1 n ∧ (key < key₁) +treeInvariant1 (node key value n@(node key₁ value₁ t t₁) m@(node key₂ value₂ t₂ t₃)) = treeInvariant1 n ∧ (key < key₁) ∧ (key₁ < key₂) ∧ treeInvariant1 m + +treeInvariantTest1 = treeInvariant1 (node 3 0 leaf (node 1 1 leaf (node 3 5 leaf leaf))) + +stackInvariant : {n : Level} {A : Set n} → (env : Env A) → Set n +stackInvariant {_} {A} env = stackInvariant-c (varl env) env where + stackInvariant-c : {n : Level} {A : Set n} → (stack : List (bt A)) → (env : Env A) → Set n + stackInvariant-c stack env with stack + ... | [] = Lift _ ⊤ + ... | x ∷ [] = Lift _ ⊤ + ... | x ∷ leaf ∷ st = Lift _ ⊥ + ... | x ∷ tail@(node key-t value ltree rtree ∷ st) = ((ltree ≡ x) ∧ stackInvariant-c tail env) ∨ ((rtree ≡ x) ∧ stackInvariant-c tail env) + +{- += Lift _ ⊤ +stackInvariant {_} {A} tree (tree1 ∷ [] ) = tree1 ≡ tree +stackInvariant {_} {A} tree (x ∷ tail @ (node key value leaf right ∷ _) ) = (right ≡ x) ∧ stackInvariant tree tail +stackInvariant {_} {A} tree (x ∷ tail @ (node key value left leaf ∷ _) ) = (left ≡ x) ∧ stackInvariant tree tail +stackInvariant {_} {A} tree (x ∷ tail @ (node key value left right ∷ _) ) = ( (left ≡ x) ∧ stackInvariant tree tail) ∨ ( (right ≡ x) ∧ stackInvariant tree tail) +stackInvariant {_} {A} tree s = Lift _ ⊥ +-} + +findP : {n m : Level} {A : Set n} {t : Set m} → (env : Env A) + → treeInvariant env ∧ stackInvariant env + → (exit : (env : Env A) → treeInvariant env ∧ stackInvariant env → t ) → t +findP env Cond exit = findP-c (vart env) env Cond exit where + findP-c : {n m : Level} {A : Set n} {t : Set m} → (tree : bt A) → (env : Env A) + → treeInvariant env ∧ stackInvariant env + → (exit : (env : Env A) → treeInvariant env ∧ stackInvariant env → t ) → t + findP-c leaf env Cond exit = exit env Cond + findP-c n@(node key-t value ltree rtree) env Cond exit with <-cmp key-t (varn env) + ... | tri< a ¬b ¬c = findP-c ltree record env {vart = ltree ; varl = (n ∷ (varl env))} {!!} exit + ... | tri≈ ¬a b ¬c = exit record env {vart = n} {!!} + ... | tri> ¬a ¬b c = findP-c rtree record env {vart = rtree ; varl = (n ∷ (varl env))} {!!} exit + +{- +findP key leaf tree0 st Pre _ exit = exit leaf tree0 st {!!} +findP key (node key₁ v tree tree₁) tree0 st Pre next exit with <-cmp key key₁ +findP key n tree0 st Pre _ exit | tri≈ ¬a b ¬c = exit n tree0 st {!!} +findP key n@(node key₁ v tree tree₁) tree0 st Pre next _ | tri< a ¬b ¬c = next tree tree0 (n ∷ st) {!!} {!!} +findP key n@(node key₁ v tree tree₁) tree0 st Pre next _ | tri> ¬a ¬b c = next tree₁ tree0 (n ∷ st) {!!} {!!} +-} + diff -r 72667e8198e2 -r 339fb67b4375 rbt/rbt.agda --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rbt/rbt.agda Sun Nov 07 00:51:16 2021 +0900 @@ -0,0 +1,2 @@ +module rbt where +