How do you derive a type $∃e(e)$ in terms of universally quantified types, without invoking Void initially?

I wrote a “proof” for this, and though it was enough to convince myself, there are a few things that bother me about it. Primarily I’m not sure about the loose way in which I’m swapping between first-order logic and the Curry-Howard correspondence, and some ancient and brief exposure to first-order logic as an undergraduate. I’m looking to keep the proof fairly intuitive, and avoid any overly clever invocations if possible (though I don’t mind hearing about them).

I’m using a possibly non-standard convention that the syntax $ ∃e(e)$ means $ ∃e(P(e))$ where $ P(e)$ means there exist a value of type $ e$ . Let $ \texttt{Void}$ denote a type devoid of any values, and assume it can be expressed as $ ∀a(a)$ in the type system, which seems a legitimate take on affairs as it would be seemingly impossible to construct a value simultaneously inhabiting every type. Then a function from $ T → \texttt{Void}$ is equivalent to $ ¬T$ by Curry-Howard, I believe.

Rather than going about it the hard way and trying to find a universal-only sentence that is implied by $ ∃e(e)$ , then proving a logical equivalence, I’ll start with a universally quantified type I’ve been given by an oracle, then show how this implies $ ∃e(e)$ .

$ $ \begin{multline} \shoveleft \begin{aligned} ∀r[∀a(a → r) → r] \ ∀r∀a(a → r) → ∀r(r) \ ∀r∀a(a → r) → \texttt{Void} \ ¬∀r∀a(a → r) \ ∃r[¬∀a(a → r)] \ ∃r[∃a(¬(a → r))] \ ∃r[∃a(¬(¬a∨r))] \ ∃r[∃a(a∧¬r)] \ \text{(provable identities) } ∃r[∃a(a)∧¬r] \ \text{(eliminate conjunction) } ∃r[∃a(a)] \ \text{(eliminate redundant quantifier) } ∃a(a) \end{aligned} \end{multline} $ $

(Apologies for the Unicode symbols, I gather it isn’t the norm, but I’m trying to collect some notes in a markdown document.)

¿Por qué me pide usar un punto y coma entre mis “()” y “{” de un private void? (android studio con java como lenguaje)

justo después de los paréntesis de “crearcuenta” me salta error porque falta un punto y coma, pero tengo entendido de que ahí no va nada de eso, que puede ser el error?

 private void crearcuenta(){              String ecorreo, epass;             if(!checkFields()){                 Toast.makeText(this, "Datos Incorrectos", Toast.LENGTH_SHORT).show();             }             else{                 ecorreo = Ecorreo.getText().toString();                 epass = Epass.getText().toString();             }         } 

Por qué “cannot convert from void to double” si la función Si devuelve un double?

Tengo una clase CalcularArea que tiene una función tipoArea que calcula el area de un Triangulo, Cuadrado, o Circulo, dependiendo que argumento se le pasa.

public class CalcularArea { 	public static Scanner input = new Scanner(System.in); 	 	public static void tipoArea(String figura) { 		switch(figura) { 		case "TRIANGULO": 			areaTriangulo(); 		case "CIRCULO": 			areaCirculo(); 		case "CUADRADO": 			areaCuadrado(); 		} 	}  	private static int areaCuadrado() { 		 System.out.println("Ingrese la longitud del lado en metros"); 		  int lado = input.nextInt(); 		  	return lado * lado; 	}  	private static double areaCirculo() { 		// TODO Auto-generated method stub 		  System.out.println("Ingrese la longitud del radio"); 		  double radio = input.nextDouble(); 		  return (3.1416 * radio * radio); 	}  	private static float areaTriangulo() { 		// TODO Auto-generated method stub 		System.out.println("Ingrese la base en metros"); 		int base = input.nextInt(); 		System.out.println("Ingrese la altura en metros"); 		int altura = input.nextInt(); 			return (base * altura) / 2; 	} }

Pongamos que la variable lafigura es “TRIANGULO”, si se la paso de la siguiente forma desde la clase Vendedor en el main:

public class Vendedor { 	 	public static void main(String[] args) throws Exception{   String lafigura = "TRIANGULO";   double Area = CalcularArea.tipoArea(lafigura);   } }   

Da error: Type mismatch: cannot convert from void to double: Pero no debería, ultimamente si estoy devolviendo un valor, void es sólo la primera función.

C++ ¿Cómo llamar a ifstream con void?

mi problema es el siguiente: Estoy creando un sistema de guardado y carga de “partidas” en C++ con codeblocks. He usado un código sencillo para crear el sistema en cuestión, pero la finalidad sería restaurar el valor de las variables alojadas en un struct (casi todas int) en un .txt o un .dat. Ya he probado varios métodos, en binario y en txt el problema es siempre el mismo, consigo guardar los datos, pero al testear los valores después de cargar de nuevo la partida, los valores de las variables no se han reestablecido.

En resumen:

1 – struct con variables

2 – asigno valores a variables

3 – void guardar variables en archivo

4 – cambio valores a variables

5 – void cargar valores en variables <—Aqui tengo el problema

6 – muestro los valores

#include<iostream> #include<fstream>  using namespace std;  ///ESTRUCTURA DE VARIABLES DEL JUEGO struct NewGame{ float tipo; float health; };  ///GUARDAR PARTIDA _ CARGAR PARTIDA void saveGame(struct NewGame(G)); void loadGame(struct NewGame(G));  int main(){  ///INCIO DE STRUCT NewGame G;  ///ASIGNAR DATOS (TESTEO) cout << "Ingrese tipo [1] [2] [3]" << endl; cin >> G.tipo; cout << "Ingrese vida"<<endl; cin >> G.health;  ///FUNCIÓN GUARDAR PARTIDA saveGame(NewGame(G));  ///CAMBIO DE VALORES DEL STRUCT G.health = 0; G.tipo = 0;  ///FUNCION CARGAR PARTIDA loadGame(NewGame(G));  ///COMPROBACIÓN cout << "HEALTH: " << G.health << endl; cout << "TYPE: " << G.tipo << endl;   return 0; }  ///GUARDAR PARTIDA void saveGame(NewGame(G)){  ofstream s;     s.open("save.txt");     s << G.health << endl;     s << G.tipo << endl;     s.close();  };  ///CARGAR PARTIDA void loadGame(NewGame(G)){  ifstream l;     l.open("save.txt");     l >> G.health;     l >> G.tipo;     l.close();  };  

Can adding a return parameter to void method break existing functionality?

Currently, I am creating some end to end tests for an API and have a method that would be perfect to use for a test except for the fact that it has a return type of void. If I were to change the return type to List, could this possibly break existing functionality somewhere within the system? My current thoughts are that all code that calls the method will not be affected as they are not using the method to assign any value to a variable. Are there any cases in which this is not true?

This is for a legacy code base, so unfortunately I am stuck with it. The codebase is too vast for me to look up all instances of code that could be affected by this change.

Передача указателя на void функцию в качестве аргумента

Вечно путаю синтаксис…

Есть функция:

void DoSMTH(int a1, int b1){     // Делаю что-то с a1 и b1 } 

Есть функция Вызывальщик

int DoSMTHwithSMTH(/* Что здесь? */){        /* ЗДЕСЬ ВЫЗОВ DoSMTH(a2, b2) */ } 

Главный поток:

int main(){     return DoSMTHwithSMTH(/* ЧТО ЗДЕСЬ? */) } 

P.S. Код вверху – пример, если хотите – можете привести свой

Pointer to void in C preprocessor

I read this source(https://github.com/lattera/glibc/blob/master/stdio-common/vfprintf.c) and find some interesting lines, which I not fully understand:

#ifdef SHARED /* 'int' is enough and it saves some space on 64 bit systems.  */ # define JUMP_TABLE_TYPE const int # define JUMP_TABLE_BASE_LABEL do_form_unknown # define REF(Name) &&do_##Name - &&JUMP_TABLE_BASE_LABEL # define JUMP(ChExpr, table)                              \   do                                      \ {                                     \   int offset;                                 \   void *ptr;                                  \   spec = (ChExpr);                            \   offset = NOT_IN_JUMP_RANGE (spec) ? REF (form_unknown)          \     : table[CHAR_CLASS (spec)];                       \   ptr = &&JUMP_TABLE_BASE_LABEL + offset;                 \   goto *ptr;                                  \ }                                     \   while (0)   ...  #define STEP0_3_TABLE                                 \ /* Step 0: at the beginning.  */                          \ static JUMP_TABLE_TYPE step0_jumps[30] =                      \ {                                         \   REF (form_unknown),                             \   REF (flag_space),     /* for ' ' */                     \   REF (flag_plus),      /* for '+' */                     \   REF (flag_minus),     /* for '-' */                     \   REF (flag_hash),      /* for '<hash>' */                \   REF (flag_zero),      /* for '0' */                     \   REF (flag_quote),     /* for '\'' */                    \   REF (width_asterics), /* for '*' */                     \   REF (width),      /* for '1'...'9' */               \   REF (precision),      /* for '.' */                     \   REF (mod_half),       /* for 'h' */                     \   ... 

I wrote simple example and understand that this line &&do_##Name cast do_##Name to pointer to void. But I don’t understand how works pointer arythmetis in this case: #define REF(Name) &&do_##Name – &&JUMP_TABLE_BASE_LABEL Can someone write simple explane? Or write some link to Internet resource where I can read about this technique best regards.

Corsair VOID Pro Sidetone

I just made the switch from Windows 10 to Ubuntu 18.04.2 LTS, and I was immediately greeted with the sidetone in my Corsair VOID Pro kicking back on. I can hear everything my microphone picks up which is pretty annoying. I heard that there wasn’t much support for peripherals in Linux, but I was hoping there was some way to at least turn off the sidetone for the headset. Any solutions?

Headset on Amazon

Не знаю, как задать переменную типа void** +Собрать запустить всё в main

#include <iostream> #include <string.h> #include <malloc.h> #include <math.h> #include <TCHAR.h> #include <conio.h> using namespace std; typedef enum _comp {     diod = 1,     lamp,     motor,     power,     time,     energy } Comp;   typedef struct _diod {     Comp kind;     int q, e; }Diod;  typedef struct _lamp {     Comp kind;     int q, e; }Lamp;  typedef struct _motor {     Comp kind;     int q, e; }Motor;  typedef struct _power {     Comp kind;     int e; }Power;  typedef struct _time {     Comp kind;     int t; }Time;  typedef struct _energy {     Comp kind;     int q, e; }Energy;  void* ppCompArray[]={NULL,NULL,NULL,NULL,NULL,NULL}; Comp comp_kind = *((Comp*)ppCompArray[0]);  Diod* CalcDiod() {     Diod* p = (Diod*)malloc(sizeof(Diod));     int a,b;     cout << "Enter Kol-vo;";     cin >> a;     cout << " Enter power;";     cin >> b;     p->kind = diod;     p->e = a*b;     return p; }  Lamp* CalcLamp() {     Lamp* p = (Lamp*)malloc(sizeof(Lamp));     int a,b;     cout << "Enter Kol-vo;";     cin >> a;     cout << " Enter power;";     cin >> b;     p->kind = lamp;     p->e = a*b;     return p; }  Motor* CalcMotor() {     Motor* p = (Motor*)malloc(sizeof(Motor));     int a,b;     cout << "Enter Kol-vo;";     cin >> a;     cout << " Enter power;";     cin >> b;     p->kind = motor;     p->e = a*b;     return p; }  Power* CalcPower() {     Power* p = (Power*)malloc(sizeof(Power));     int a,b;     cout << "Enter Kol-vo;";     cin >> a;     cout << " Enter power;";     cin >> b;     p->kind = power;     p->e = a*b;     return p; }  Time* CalcTime() {     Time* p = (Time*)malloc(sizeof(Time));     int a,b;     cout << "Enter Kol-vo;";     cin >> a;     cout << " Enter power;";     cin >> b;     p->kind = time;     p->t = a*b;     return p; }  Energy* CalcEnergy() {     Energy* p = (Energy*)malloc(sizeof(Energy));     int a,b;     cout << "Enter Kol-vo;";     cin >> a;     cout << " Enter power;";     cin >> b;     p->kind = energy;     p->e = a*b;     return p; }   int AddComp(void** ppComp) {  int counter = 0;  bool quit = false;  while(!quit)  {  if(counter > 3)  return counter;  printf("Enter Figure Kind: \n");  printf("1 - diod;\n");  printf("2 - lamp;\n");  printf("3 - motor;\n");   printf("4 - power;\n");    printf("5 - time;\n");  printf("6 - energy;\n");  printf("e - Exit.\n\n");   int key;  switch(key)  {  case '1':  {   Diod* c = CalcDiod();  if(c != NULL)   {  ppComp[counter] = c;  counter++;  }  break;  }  case '2':  {   Lamp* r = CalcLamp();  if(r != NULL)   {      ppComp[counter] = r;   counter++;  }  break;  }  case '3':  {  Motor* w = CalcMotor();  if(w != NULL)   {  ppComp[counter] = w;  counter++;  } break;  }    case '4':  {  Power* d = CalcPower();  if(d != NULL)   {  ppComp[counter] = d;  counter++;  } break;  }    case '5':  {  Time* f = CalcTime();  if(f != NULL)   {  ppComp[counter] = f;  counter++;  } break;  }    case '6':  {  Energy* s = CalcEnergy();  if(s != NULL)   {  ppComp[counter] = s;  counter++;  }   break;   }  case '7':  {  printf("%d elements were created.\n\n", counter);  return counter;  break;  default:  printf("Enter correct number. Try again of Exit.\n");  }  }  printf("%d elements were created", counter);  return counter;  } }  float GetComP(void** ppComp, int count) {  float P = 0;   for(int i = 0; i < count; i++)  {  void* p = ppComp[i];    Comp kind = *((Comp*)p);  switch(kind)  {  case diod:  P += (float)((Diod*)p)->e;  break;  case lamp:  P += (float)((Lamp*)p)->e;  break;   case motor:  P += (float)((Motor*)p)->e;  break;   case power:  P += (float)((Power*)p)->e;  break;   case time:  P += (float)((Time*)p)->t;  break;   case energy:  P += (float)((Energy*)p)->e;  break;   default:   printf("Error in calculation of Power!!! \n");  return 0;  }  }  return P; }  int _tmain(int argc, _TCHAR* argv[]) {      cin >> ppCompArray[0];     void* l -   int realCount = 0; float s = GetComP(ppCompArray,realCount);  printf("Power of element: %d", s);  return 0; }