diff --git a/logic.py b/logic.py index 164e586e5b5af9f5b8581b9b77f52602147baf78..4fa1b8282429d4a5eb88f4589efd4ac2570ca4fc 100644 --- a/logic.py +++ b/logic.py @@ -480,7 +480,7 @@ def beta_reduction_choice_n(terme,n): def beta_reduction_interactive(terme, at): global counters if at != None: - # print(annotated_to_string(at)) + print(annotated_to_string(at)) choice = int(input("Choose a beta reduction: ")) while choice <= 0 or choice > counters: print("Invalid choice") @@ -503,7 +503,7 @@ def cleanReductions(l): def beta_reduction_interactive_totale(terme,path): if beta_reduction((terme)) != None: - # print(to_string(terme)) + #print(to_string(terme)) at = (annotate_beta_reduction((terme))) captureImage(at,path) choix=int(input("voulez-vous faire la reduction tapez sur 1 pour oui tapez sur 2 pour non ")) diff --git a/main.py b/main.py index a717a7100b3042494ee136677db3d65ba18797cf..cff75061db93dcbc4b6447fcde9627cf9adf081b 100644 --- a/main.py +++ b/main.py @@ -92,15 +92,16 @@ def run_beta_reduction_totale(terme,path='beta_reduction_totale'): os.makedirs(path, exist_ok=True)# cree le rep si il existe pas, le vide si non if len(os.listdir(path)) > 0: logic.image_counter = 0 - logic.beta_reduction_totale(terme,path) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images? (y/n): ') - if save_image_choice == 'y': + k=logic.beta_reduction_totale(terme,path) + print(" le terme obtenu est: "+logic.to_string(k)) + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) - elif save_image_choice == 'n': + elif save_image_choice=='n': delete_images(path) os.rmdir(path) @@ -113,10 +114,10 @@ def run_beta_reduction_interactive_totale(terme,path='beta_reduction_interactive if len(os.listdir(path)) > 0: logic.image_counter = 0 logic.beta_reduction_interactive_totale(terme,path) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (Y/n): ') + if save_image_choice == 'y'or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -138,10 +139,10 @@ def run_show_numbers(path): t = app_functions.dec_to_church(terme) print('Voici le terme:',logic.to_string(t)) logic.captureImage(t,path,'ENTIER'+str(terme),False) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -155,10 +156,10 @@ def run_show_numbers(path): t = app_functions.dec_to_lambda_relative_integers(terme) print('Voici le terme:',logic.to_string(t)) logic.captureImage(t,path,'ENTIER-RELATIF-'+str(terme),False) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -181,10 +182,10 @@ def run_boolean_expression(path): t = app_functions.NOT print('Voici le terme:',logic.to_string(t)) logic.captureImage(t,path,'NOT',False) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -196,10 +197,10 @@ def run_boolean_expression(path): t = app_functions.AND print('Voici le terme:',logic.to_string(t)) logic.captureImage(t,path,'AND',False) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -211,10 +212,10 @@ def run_boolean_expression(path): t = app_functions.OR print('Voici le terme:',logic.to_string(t)) logic.captureImage(t,path,'OR',False) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -226,10 +227,10 @@ def run_boolean_expression(path): t = app_functions.XOR print('Voici le terme:',logic.to_string(t)) logic.captureImage(t,path,'XOR',False) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -242,10 +243,10 @@ def run_boolean_expression(path): t = app_functions.IS_ZERO print('Voici le terme:',logic.to_string(t)) logic.captureImage(t,path,'IS_ZERO',False) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -322,19 +323,19 @@ def run_arithmetic_operations_menu(path='arithmetic expressions'): clear() print("Voici le terme: "+ logic.to_string(app_functions.ADD)) logic.captureImage(app_functions.ADD,path,'ADD', False) - choix=(input("do you want to try an exemple? (y/n) : ")) - while choix not in ['y','n']: - choix = input('Invalid choice. Do you want to try an exemple? (y/n): ') - if choix=='y': + choix=(input("do you want to try an exemple? (Y/n) : ")) + while choix not in ['y','n','']: + choix = input('Invalid choice. Do you want to try an exemple? (Y/n): ') + if choix=='y' or choix=='': clear() print("you are going to try n+m") n=int(input("give n : ")) m=int(input("give m : ")) app_functions.add(app_functions.dec_to_church(n),app_functions.dec_to_church(m)) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -346,19 +347,19 @@ def run_arithmetic_operations_menu(path='arithmetic expressions'): clear() print("Voici le terme: "+ logic.to_string(app_functions.SUB)) logic.captureImage(app_functions.SUB,path,'SUB', False) - choix=(input("do you want to try an exemple? (y/n) : ")) - while choix not in ['y','n']: - choix = input('Invalid choice. Do you want to try an exemple? (y/n): ') - if choix=='y': + choix=(input("do you want to try an exemple? (Y/n) : ")) + while choix not in ['y','n','']: + choix = input('Invalid choice. Do you want to try an exemple? (Y/n): ') + if choix=='y' or choix=='': clear() print("you are going to try n-m") n=int(input("give n : ")) m=int(input("give m : ")) app_functions.sub(app_functions.dec_to_church(n),app_functions.dec_to_church(m)) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['Y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -370,19 +371,19 @@ def run_arithmetic_operations_menu(path='arithmetic expressions'): clear() print("Voici le terme: "+ logic.to_string(app_functions.MUL)) logic.captureImage(app_functions.MUL,path,'MUL',False) - choix=(input("do you want to try an exemple? (y/n) : ")) - while choix not in ['y','n']: - choix = input('Invalid choice. Do you want to try an exemple? (y/n): ') - if choix=='y': + choix=(input("do you want to try an exemple? (Y/n) : ")) + while choix not in ['y','n','']: + choix = input('Invalid choice. Do you want to try an exemple? (Y/n): ') + if choix=='y' or choix=='': clear() print("you are going to try n*m") n=int(input("give n : ")) m=int(input("give m : ")) app_functions.mul(app_functions.dec_to_church(n),app_functions.dec_to_church(m)) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -394,19 +395,19 @@ def run_arithmetic_operations_menu(path='arithmetic expressions'): clear() print("Voici le terme: "+ logic.to_string(app_functions.POW)) logic.captureImage(app_functions.POW,path,'POWER',False) - choix=(input("do you want to try an exemple? (y/n) : ")) - while choix not in ['y','n']: - choix = input('Invalid choice. Do you want to try an exemple? (y/n): ') - if choix=='y': + choix=(input("do you want to try an exemple? (Y/n) : ")) + while choix not in ['y','n','']: + choix = input('Invalid choice. Do you want to try an exemple? (Y/n): ') + if choix=='y' or choix=='': clear() print("you are going to try n puiss m") n=int(input("give n : ")) m=int(input("give m : ")) app_functions.power(app_functions.dec_to_church(n),app_functions.dec_to_church(m)) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -418,18 +419,18 @@ def run_arithmetic_operations_menu(path='arithmetic expressions'): clear() print("Voici le terme: "+ logic.to_string(app_functions.SUCCS)) logic.captureImage(app_functions.SUCCS,path,'SUCCS',False) - choix=(input("do you want to try an exemple? (y/n) : ")) - while choix not in ['y','n']: - choix = input('Invalid choice. Do you want to try an exemple? (y/n): ') - if choix=='y': + choix=(input("do you want to try an exemple? (Y/n) : ")) + while choix not in ['y','n','']: + choix = input('Invalid choice. Do you want to try an exemple? (Y/n): ') + if choix=='y'or choix=='': clear() print("you are going to try n+1") n=int(input("give n : ")) app_functions.succ(app_functions.dec_to_church(n)) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images ? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path) @@ -441,18 +442,18 @@ def run_arithmetic_operations_menu(path='arithmetic expressions'): clear() print("Voici le terme: "+ logic.to_string(app_functions.PRED)) logic.captureImage(app_functions.PRED,path,'PRED',False) - choix=(input("do you want to try an exemple? (y/n) : ")) - while choix not in ['y','n']: - choix = input('Invalid choice. Do you want to try an exemple? (y/n): ') - if choix=='y': + choix=(input("do you want to try an exemple? (Y/n) : ")) + while choix not in ['y','n','']: + choix = input('Invalid choice. Do you want to try an exemple? (Y/n): ') + if choix=='y' or choix=='': clear() print("you are going to try n-1") n=int(input("give n : ")) app_functions.predec(app_functions.dec_to_church(n)) - save_image_choice = input('Do you want to save the images? (y/n): ') - while save_image_choice not in ['y','n']: - save_image_choice = input('Invalid choice. Do you want to save the images of the reduction? (y/n): ') - if save_image_choice == 'y': + save_image_choice = input('Do you want to save the images? (Y/n): ') + while save_image_choice not in ['y','n','']: + save_image_choice = input('Invalid choice. Do you want to save the images? (Y/n): ') + if save_image_choice == 'y' or save_image_choice=='': os.makedirs("./sauvegarde/"+path, exist_ok=True) moveImages(path,'./sauvegarde/'+path) os.rmdir(path)