This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Sound and Complete Flow Typing with Unions, | |
% Intersections and Negation | |
% https://ecs.wgtn.ac.nz/foswiki/pub/Main/TechnicalReportSeries/ECSTR12-20.pdf | |
:- op(1200,xfx,::=),op(650,xfx,∈),op(250,yf,*),op(600,xfy,[&,$]). | |
G∈{G}. G∈(G|_). G∈(_|G1):-G∈G1. G∈G. | |
syntax(G,E):-G=..[O|Gs],E=..[O|Es],maplist(syntax,Gs,Es),!. | |
syntax(G,E):-(G::=Gs),!,G1∈Gs,syntax(G1,E),!. | |
syntax(i,I):-integer(I),!. | |
syntax(E*,Ls):-maplist(syntax(E),Ls). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Definition x := nat. | |
Inductive t:=X:x->t|True:t|False:t|N:t->t|A:t*t->t|O:t*t->t. | |
Inductive n:=NX:x->n|NTrue:n|NFalse:n|NN:x->n|NA:n*n->n|NO:n*n->n. | |
Fixpoint t2n(t0:t):n := | |
match t0 with | |
| N(a) => t2nneg a | |
| A(a,b) => NO(t2n a,t2n b) | |
| O(a,b) => NA(t2n a,t2n b) | |
| X x => NX x | |
| True => NTrue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Definition x := nat. | |
Inductive t:=X:x->t|True:t|False:t|N:t->t|A:t*t->t|O:t*t->t. | |
Inductive n:=NX:x->n|NTrue:n|NFalse:n|NNX:x->n|NA:n*n->n|NO:n*n->n. | |
Fixpoint nnf(t0:t):n := | |
match t0 with | |
| N(a) => neg a | |
| A(a,b) => NO(nnf a,nnf b) | |
| O(a,b) => NA(nnf a,nnf b) | |
| X x => NX x | |
| True => NTrue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- op(1100,xfy,&). | |
:-op(600,xfy,=>). | |
:-op(700,xfy,<=>). | |
n(-(-A),A1):-!,n(A,A1). | |
n(-(A&B),R):-!,n(-A,A1),n(-B,B1),d(A1|B1,R). | |
n(-(A|B),R):-!,n(-A,A1),n(-B,B1),d(A1&B1,R). | |
n(A&B,R):-!,n(A,A1),n(B,B1),d(A1&B1,R). | |
n(A|B,R):-!,n(A,A1),n(B,B1),d(A1|B1,R). | |
n(-true,false). | |
n(-false,true). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- module(fjv,[init/0,syntax/2,(<:)/2,fields/2,ftype/3,split/3, | |
mtype/3,(/-)/2,okall/0,run/1]). | |
% ------------------------ SYNTAX ------------------------ | |
init :- op(920,xfx,[=>,=>*]),op(910,xfx,[/-]), | |
op(501,xfx,<:),op(500,xfy,∨),op(511,yfx,#),op(510,xfx,!), | |
op(1200,xfx,::=),op(650,xfx,∈),op(250,yf,*),op(999,fx,class). | |
:- init. | |
G∈{G}. G∈(G|_). G∈(_|G1):-G∈G1. G∈G. | |
syntax(G,E):-G=..[O|Gs],E=..[O|Es],maplist(syntax,Gs,Es),!. | |
syntax(G,E):-(G::=Gs),!,G1∈Gs,syntax(G1,E),!. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyswip import Prolog | |
from pyswip import Functor | |
from pyswip.prolog import PrologError | |
DEFAULT_LIMIT = 10 | |
ini = False | |
def init(prolog): | |
global ini | |
if ini: return prolog | |
ini = True | |
prolog.assertz("""get_labapp(A) :- retract(outs(A))""") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spaceN(N,R2):-findall(' ',between(1,N,_),R),concat_atom(R,R2). | |
pprint(FP,T) :- tell(FP),pprint(T),tell(user_output). | |
pprint(T) :- pprint1(0,T),writeln(.). | |
pprint1(_,T) :- atomic(T),print(T). | |
pprint1(N,T) :- format(atom(V),'~p',[T]),atom_length(V,N1),N2 is N1+N,N2 < 80,write(V). | |
pprint1(N,T) :- is_list(T), writeln('['),N1 is N+1,pplist(N1,T),printSpace(N),write(']'). | |
pprint1(N,A:B) :- writeq(A),write(:),pprint1(N,B). | |
pprint1(N,A) :- A =..[P|Ps], write(P),write('('),ppparams(N,Ps),write(')'). | |
ppparams(_,[]). | |
ppparams(N,[A]):-pprint1(N,A). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Welsh-Powell-Algorithm | |
function coloring(es) { | |
var ns = neighbors(es),cs = {}, c = 0 | |
ns.sort(([_a1,e1],[_a2,e2])=>e2.length-e1.length) | |
ns.forEach(([a1,e1],i)=>(a1 in cs || (cs[a1] = ++c), | |
ns.slice(i+1).forEach(([a,e])=> | |
a in cs||e1.includes(a)||e.some(v=>cs[v]==c)||(cs[a]=c)))) | |
return [cs,es] | |
} | |
// 隣を求める |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- A=a{x:10,y:20},nb_set_dict(x,A,5),writeln(A). | |
:- expects_dialect(sicstus). | |
:- time(forall(between(0,100000,I),(b_setval(a,I),b_getval(a,_)))). | |
:- time(forall(between(0,100000,I),(nb_linkval(a,I),nb_getval(a,_)))). | |
:- time(forall(between(0,100000,I),(nb_setval(a,I),nb_getval(a,_)))). | |
:- time(forall(between(0,100000,I),(bb_put(a,I),bb_get(a,_)))). | |
:- time(forall(between(0,100000,I),(retractall(a(_)),assert(a(I)),a(_)))). | |
:- assert(a(0)),time(forall(between(0,100000,I),(retract(a(_)),assert(a(I)),a(_)))). | |
:- writeln(---). | |
:- b_setval(a,hoge(0)),time(forall(between(0,1000000,_),(b_getval(a,_)))). |