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

fixed beta_reduction_choice_n

parent aa02cfe2
No related branches found
No related tags found
No related merge requests found
......@@ -343,8 +343,8 @@ def annotated_to_string(terme):
if isApplication(terme):
first=getFirstTerm(terme)
second=getSecondTerm(terme)
String_term+= annotated_to_string(first)
String_term+=annotated_to_string(second)
String_term+='(' + annotated_to_string(first) + ') '
String_term+= '('+ annotated_to_string(second) + ') '
elif isAbstraction(terme):
String_term+='#'+ to_string(getInputFromAbs(terme))+ '.' +annotated_to_string(getOutputFromAbs(terme))
else:
......@@ -381,6 +381,20 @@ def beta_reduction_choice_n(terme,n):
return new_app(A1,beta_reduction_choice_n(B1,n))
if A2 == None and B2 == None:
return None
else:
terme = terme[:3]
A1 = getFirstTerm(terme)
B1 = getSecondTerm(terme)
A2 = beta_reduction_choice_n(A1,n)
B2 = beta_reduction_choice_n(B1,n)
if A2 != None and B2 != None:
return new_app(beta_reduction_choice_n(A1,n),beta_reduction_choice_n(B1,n))
if A2 != None and B2 == None:
return new_app(beta_reduction_choice_n(A1,n),B1)
if A2 == None and B2 != None:
return new_app(A1,beta_reduction_choice_n(B1,n))
if A2 == None and B2 == None:
return None
def beta_reduction_interactive(terme):
at = annotate_beta_reduction(terme)
......
......@@ -74,13 +74,13 @@ from logic import *
# # print(findClosingParanthesesIndex('()',0))
x=new_var(freshVar())
y=new_var(freshVar())
z=new_var(freshVar())
term= new_app(new_abs(x,x),new_app(new_abs(y,y),z))
# x=new_var(freshVar())
# y=new_var(freshVar())
# z=new_var(freshVar())
# term= new_app(new_abs(x,x),new_app(new_abs(y,y),z))
# #print(annotated_to_string(annotate_beta_reduction(term)))
# print(annotated_to_string(beta_reduction_choice_n(annotate_beta_reduction(term),1)))
import parsing
#print(annotated_to_string(x))
#beta_reduction_interactive_totale(parsing.parseTerm(input("Enter a term: ")))
beta_reduction_interactive_totale(term)
\ No newline at end of file
beta_reduction_interactive_totale(parsing.parseTerm(input("Enter a term: ")))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment