Skip to content
Snippets Groups Projects
Commit 1eb7d601 authored by Tamazouzt AIT ELDJOUDI's avatar Tamazouzt AIT ELDJOUDI
Browse files

added arithmetic and logic fubctions to app_func

parent 48855d4c
Branches
No related tags found
No related merge requests found
......@@ -5,8 +5,9 @@ from image_maker import*
f=new_var(freshVar())
x=new_var(freshVar())
y=new_var(freshVar())
# z=new_var(freshVar())
# w=new_var(freshVar())
z=new_var(freshVar())
w=new_var(freshVar())
succs= new_abs(z,new_abs(f,new_abs(x,new_app(new_app(z,f), new_app(f,x)))))
boolean={True: new_abs(x,new_abs(y,x)), False: new_abs(x,new_abs(y,y))}
#definition des entiers de church
......@@ -34,6 +35,24 @@ def dec_to_lambda_relative_integers(number):
return pair(boolean[True],dec_to_church(number))
return pair(boolean[False], dec_to_church(number))
def succ(n):
return beta_reduction_totale(new_abs(f,new_abs(x,new_app(new_app(n,f), new_app(f,x)))))
def adder(n,m):
return beta_reduction_totale(new_app(new_app(m,succs),n))
def power(n,m):# retourne n puiss m
return beta_reduction_totale(new_app(m,n))
def multiplication(n,m):
return beta_reduction_totale(new_abs(f,new_abs(x,new_app(m,new_app(n,f)))))
def is_zero(n):
return beta_reduction_totale(new_app(new_app(n,new_abs(x,boolean[False])),boolean[True]))
#print(to_string(getSecondFromPair(pair(boolean[True],dec_to_church(1)))))
print(to_string(pair(x,y)))
print(to_string(is_zero(dec_to_church(3))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment